Re: [R] How to read many files at one time?

2007-07-16 Thread Don MacQueen
Storing them as elements of list is fine, but if you want them as individual objects, then something like this (not tested): for (i in seq( length(tst) ) ) { tmp - read.table( tst[i] )## or read.delim() or read.csv(), as necessary assign( data.name[i], tmp ) } -Don At 3:16 PM

[R] How to read many files at one time?

2007-07-14 Thread Zhang Jian
I want to load many files in the R. The names of the files are Sim1.txt, Sim2.txt, Sim3.txt, Sim4.txt, Sim5.txt and so on. Can I read them at one time? What should I do? I can give the same names in R. Thanks. For example: tst=paste(Sim,1:20,.txt,sep=) # the file names tst [1] Sim1.txt

Re: [R] How to read many files at one time?

2007-07-14 Thread Mike Lawrence
On 14-Jul-07, at 6:16 PM, Zhang Jian wrote: I want to load many files in the R. The names of the files are Sim1.txt, Sim2.txt, Sim3.txt, Sim4.txt, Sim5.txt and so on. Can I read them at one time? What should I do? I can give the same names in R. Thanks. For example:

Re: [R] How to read many files at one time?

2007-07-14 Thread Stephen Tucker
This should do it: allData - sapply(paste(Sim,1:20,sep=), function(.x) read.table(paste(.x,txt,sep=.)), simplify=FALSE) see ?read.table for specification of delimiters, etc. allData will be a list, and you can access the contents of each file by any of the