[R] a for loop to lapply

Alaios alaios at yahoo.com
Wed Mar 30 08:31:26 CEST 2011


Dear all,
I am trying to learn lapply.
I would like, as a test case, to try the lapply alternative for the 


Shadowlist<-array(data=NA,dim=c(dimx,dimy,dimmaps))
for (i in c(1:dimx)){
    Shadowlist[,,i]<-i
}


---so I wrote the following---


returni <-function(i,ShadowMatrix) {ShadowMatrix<-i}
lapply(seq(1:dimx),Shadowlist[,,seq(1:dimx)],returni)

So far I do not get same results with both ways.
Could you please help me understand what might be wrong?


Regards
Alex



More information about the R-help mailing list