[R] renaming an object
Natalie Roberts
nroberts at wehi.EDU.AU
Mon Oct 16 05:58:00 CEST 2000
Say I have a file called exp.batch which contains 2 cols
The first col contains names of R objects the user would like to use.
The second col contains the file names which will be read in using
read.table
i.e. exp.batch may look like this.....
name1 complex/filename/path1.txt
name2 complex/filename/path2.txt
name3 complex/filename/path3.txt
name4 complex/filename/path4.txt
I want to have a function which will read in the files and make them into
the objects named in the 1st column - automatically (by just providing
exp.batch)
for(i in 1:nrow(exp.batch)){
tmp<-read.table(as.name(exp.batch[i,2]),...)
##
##But now I really want tmp to be as.name(exp.batch[i,1])???
## so that I can call the data from complex/filename/path1.txt
## by typing name1
}
In the end I should have objects name1, name2, name3, name4
which are the names stored in the 1st column of exp.batch
The basic idea is having to avoid typing out all this!
name1<-read.table("file1",....)
name2<-read.table("file2",....)
..
..
..
nameN<-read.table("fileN",...)
Does anyone have any suggestions?
Thanks in advance,
Natalie
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list