alaios wrote:
>
> 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) {S
Hi Alex,
lapply is not a substitute for for, so it not only does things
differenly, it does a different thing.
> Shadowlist<-array(data=NA,dim=c(dimx,dimy,dimmaps))
> for (i in c(1:dimx)){
> Shadowlist[,,i]<-i
> }
Note that your test case is not reproducible as you haven't defined
dimx, dimy
//biomath.ugent.be
wink: A1.056, Coupure Links 653, 9000 Gent
ring: 09/264.59.36
-- Do Not Disapprove
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Alaios
Sent: woensdag 30 maart 2011 8:31
To: R-help@r-project.org
Subject: [R] a f
Hi Alaios,
there are some problems with your code:
1. In the expression "Shadowlist[,,i]<-i", i corresponds to dimmaps, not
dimx. The for loop should be either
for (i in c(1:dimmaps)){
Shadowlist[,,i]<-i
}
or
for (i in c(1:dimx)){
Shadowlist[i,,]<-i
}
2. in lapply, the function must
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}
la
5 matches
Mail list logo