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
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
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:
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