[R] Modifying dim attribute of elements of a list

Giovanni Petris GPetris at uark.edu
Fri Oct 17 18:50:29 CEST 2003


I am creating lists of vectors withing a loop. I also would like to
change the dim attribute to the vectors in order to make them
matrices. 

I have tried the following, but it doesn't work...

> sim <- c('simMeans','simVars','simWeights')
> indexTable <- table(modelIndex)
> for (i in sim) {
+     assign(tmp <- paste(i,'By',sep=''),split(get(i), modelIndex))
+     lapply(seq(along=indexTable),function(j) attr(get(tmp)[[j]],'dim') <<- c(indexTable[j],K))
+ }
Error in FUN(X[[1]], ...) : couldn't find function "get<-"
In addition: Warning message: 
argument lengths differ in: split(x, f) 

Any suggestions will be appreciated. 
Thanks




More information about the R-help mailing list