felber wrote:
> hello cracks,
>
> we have 365 objects (d.data1-d.data365) containing each 1200 rows with 7
> variables. now we want 1200 objects with the row number i (1:1200) of each
> d.data.
>
> we tried it to do this way: for (k in 1:1200) for (j in 1:365) for (i in
> 1:7) get(paste("test",k,sep=""))[j,i] <-
get(paste("d.data",j,sep=""))[k,i]
> -> following error appeared: Error: Target of assignment expands to
> non-language object
>
> Does anyone know what can be done?
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
>
>
> thanks in advance,
>
> Andi
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._