[R] From nested loop to mclapply

From: Alaios <alaios_at_yahoo.com>
Date: Mon, 18 Apr 2011 08:53:43 -0700 (PDT)


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



R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 18 Apr 2011 - 15:57:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 18 Apr 2011 - 16:50:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive