[R] From nested loop to mclapply
Alaios
alaios at yahoo.com
Mon Apr 18 17:53:43 CEST 2011
Dear all,
I am trying to find a decent way to speed up my code.
So far I have used mclapply with really good results (parallel version of lapply). I have a nested loop that I would like to help me convert it to lapply
for (i in seq(from=-1,to=1-2/ncol(sr),length=ncol(sr))){
for (j in seq(from=-1,to=1-2/nrow(sr),length=nrow(sr))){
estimatedsr[findCoord(c(i,j),sr)[1],findCoord(c(i,j),sr)[2] ]<-fxy(c(i,j))
}
So far I have converted some one-depth for loops to lapply but I am not sure If I can use lapply to convert a nested loop to something simpler.
Best Regards
Alex
More information about the R-help
mailing list