Re: [R] Automatic File Reading [Broadcast]

2006-10-28 Thread ronggui
2006/10/29, Wensui Liu <[EMAIL PROTECTED]>: Andy, First of all, thanks for your solution. When I test your code, it doesn't work. I am not sure if I miss something. Here is the code I tested: flist<-list.files(path = file.path(, "c:\\"),pattern="[.]csv$") First of all, I think the command sho

Re: [R] Automatic File Reading [Broadcast]

2006-10-28 Thread Wensui Liu
Andy, First of all, thanks for your solution. When I test your code, it doesn't work. I am not sure if I miss something. Here is the code I tested: flist<-list.files(path = file.path(, "c:\\"),pattern="[.]csv$") csvlist<-lapply(flist, read.csv, header = TRUE) Here is the error: Error in file(fi

Re: [R] Automatic File Reading [Broadcast]

2006-10-18 Thread Liaw, Andy
Works on all platforms: flist <- list.files(path=file.path("somedir", "somewhere"), pattern="[.]csv$") csvlist <- lapply(flist, read.csv, header=TRUE) whateverList <- lapply(csvlist, whatever) Andy From: Richard M. Heiberger > > Wensui Lui asks: > > is there a similar way t

Re: [R] Automatic File Reading

2006-10-18 Thread Richard M. Heiberger
Wensui Lui asks: > is there a similar way to read all txt or csv files with same > structure from a folder? On Windows I use this construct to find all files with the specified wild card name. I used the "\\" in the file paths with the translate=FALSE, because the "/" in the DOS switches "/w/B"

Re: [R] Automatic File Reading

2006-10-18 Thread Wensui Liu
is there a similar way to read all txt or csv files with same structure from a folder? thanks. On 10/18/06, Jerome Asselin <[EMAIL PROTECTED]> wrote: > On Wed, 2006-10-18 at 17:09 +0200, Lorenzo Isella wrote: > > Dear All, > > I am given a set of files names as: > > velocity1.txt > > velocity2.tx

Re: [R] Automatic File Reading

2006-10-18 Thread bogdan romocea
cionforbai > Sent: Wednesday, October 18, 2006 12:04 PM > To: Lorenzo Isella > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] Automatic File Reading > > Just to complete: if you need them all at the same time: > > for(i in 1:100) > { > fn <- paste("velocity"

Re: [R] Automatic File Reading

2006-10-18 Thread Charles C. Berry
There have been many threads on this topic. The posting guide would suggest you do something like this before posting to the list: > RSiteSearch("reading many files") Which reveals many relevant threads, such as: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/84176.html htt

Re: [R] Automatic File Reading

2006-10-18 Thread Scionforbai
Just to complete: if you need them all at the same time: for(i in 1:100) { fn <- paste("velocity",i,".txt",sep="") varname <- paste("velocity",i,sep="") assign(varname,read.csv(fn)) } and you have a list of objects {velocity1, ..., velocity100} with corresponding data. Scionforbai ___

Re: [R] Automatic File Reading

2006-10-18 Thread Doran, Harold
See ?read.table and the FAQs on importing data > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Lorenzo Isella > Sent: Wednesday, October 18, 2006 11:09 AM > To: r-help@stat.math.ethz.ch > Subject: [R] Automatic File Reading >

Re: [R] Automatic File Reading

2006-10-18 Thread Jerome Asselin
On Wed, 2006-10-18 at 17:09 +0200, Lorenzo Isella wrote: > Dear All, > I am given a set of files names as: > velocity1.txt > velocity2.txt > and so on. > I am sure there must be a way to read them automatically in R. > It is really taking me longer to read them than to analyze them. > Anybody has

[R] Automatic File Reading

2006-10-18 Thread Lorenzo Isella
Dear All, I am given a set of files names as: velocity1.txt velocity2.txt and so on. I am sure there must be a way to read them automatically in R. It is really taking me longer to read them than to analyze them. Anybody has a suggestion to help me out with this? Many thanks Lorenzo

Re: [R] Automatic file reading

2004-11-25 Thread Douglas Bates
Sean Davis wrote: If you simply want read all files in a given directory, you can do something like: fullpath = "/home/andersm/tmp" filenames <- dir(fullpath,pattern="*") pair <- sapply(filenames,function(x) {read.table(paste(fullpath,'/',x,sep=""))}) Slightly off-topic but it is more portable t

Re: [R] Automatic file reading

2004-11-24 Thread Sean Davis
If you simply want read all files in a given directory, you can do something like: fullpath = "/home/andersm/tmp" filenames <- dir(fullpath,pattern="*") pair <- sapply(filenames,function(x) {read.table(paste(fullpath,'/',x,sep=""))}) Sorry, untested. But the point is that you can use dir to ge

Re: [R] Automatic file reading

2004-11-24 Thread Arne Henningsen
Hi Andreas, what's about: pair <- list() for (i in 1:8){ name <- paste("pair",i,sep="") pair[[ i ]] <- read.table(paste("/home/andersm/tmp/",name,sep="")) } Arne On Wednesday 24 November 2004 12:10, Anders Malmberg wrote: > Hi, > > I want to do automatic reading of a number of tables (file

Re: [R] Automatic file reading

2004-11-24 Thread Uwe Ligges
Anders Malmberg wrote: Hi, I want to do automatic reading of a number of tables (files) stored in ascii format without having to specify the variable name in R each time. Below is an example of how I would like to use it (I assume files pair1,...,pair8 exist in spec. dire.) for (i in 1:8){ na

Re: [R] Automatic file reading

2004-11-24 Thread Adaikalavan Ramasamy
for(i in 1:10){ assign( paste("data", i), i ) } > data1 [1] 1 > data5 [1] 5 > data8 + data5 [1] 13 See help("assign") for more details and examples. On Wed, 2004-11-24 at 11:10, Anders Malmberg wrote: > Hi, > > I want to do automatic reading of a number of tables (files) stored in > ascii form

[R] Automatic file reading

2004-11-24 Thread Anders Malmberg
Hi, I want to do automatic reading of a number of tables (files) stored in ascii format without having to specify the variable name in R each time. Below is an example of how I would like to use it (I assume files pair1,...,pair8 exist in spec. dire.) for (i in 1:8){ name <- paste("pair",i,se