[R] creating and calling objects based on elements of another object...

Warren geelewis at gmail.com
Sat Nov 18 01:50:39 CET 2006


Hi R community,

I'd like to automatically create a number of matrices named for
elements of another list or matrix.

#I'm planning to deposit data into matrices named for plates in a platelist
platelist<- c("G2625462", "G2625464", "G2625466", "G2625468",
"G2625470", "G2625472", "G2625474", "G2625476", "G2625478",
"G2625480", "G2659264", "G2659266", "G2659268", "G2659270",
"G2659272", "G2659274", "G2659276", "G2659278", "G2659280",
"G2661382", "G2661384", "G2661386", "G2661388", "G2661390",
"G2661392", "G2661394", "G2661396", "G2661398", "G2661400",
"G2661412", "G2661414", "G2661416", "G2661418", "G2661420",
"G2661562", "G2661564", "G2661568", "G2661570", "G2661576",
"G2661578", "G2661580")
platenumber<-length(platelist)

#failed attempt to create places to put data from each plate above
platenumber<-length(platelist)
for (i in 1:platenumber){
as.name(platelist[i])<-matrix()
}

#eventually I would like to use these matrices to read in the contents
of multiple files, but using as.name hasn't worked her either.
for (i in 1:fileno){
as.name(plateID[i])<-cbind(as.name(plateID[i]),read.delim(myfilenames[i],
header=FALSE))
}

I have been trying multiple functions to force evaluation and treat
these elements as objects, and I get errors like: could not find
function "as.name<-"
Directly trying to create matrices doesn't work like this:
> for (i in 1:platenumber){
+ platelist[i]<-matrix()
+ }
> platelist
 [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA

I am exploring the alternative of making an immense dataframe, and I'm
trying to get through the R language definition documentation to build
these functions--any expert advice would be tremendously helpful.
Thanks for your time.

Cheers,
Warren

Warren G. Lewis
geelewis at gmail.com



More information about the R-help mailing list