Skip to content
Prev 14193 / 398506 Next

Create objects

YJ
felber wrote:

            
hmm, the manual says that
#assign does not dispatch assignment methods,
#so it cannot be used to set elements of vectors, names, attributes, etc.

as a crude work-around in R you can use arrays as in this toy example which worked
as expected as long
as the columns are all numeric
#> dim(fi1)   [1] 10 9
#> dim(fi2)   [1] 10 9 ....
#
blah<-array(NA,dim=c(4,10,9))
for( k in 1:4)
{
 for( i in 1:10)
 {
  for( j in 1:9)
  {
  blah[k,i,j]<-eval(parse(text=paste("fi",k,sep="")))[i,j]
  }
 assign(paste("oops",i,sep=""),eval(parse(text=paste("blah[,",i,",]",sep=""))) )
 }
}

of course, the assign() is redundant and only needed if you need objects with
numbering ending in i, in your case 1 through 1200;
But I bet there are more efficient ways to handle your problem
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._