[R] For->lapply->parallel apply

From: Alaios <alaios_at_yahoo.com>
Date: Sat, 09 Apr 2011 02:03:14 -0700 (PDT)

Dear all,
I would like to ask your help understand the subsequent steps for making my program faster.

The following code:
for (i in c(1:dimz)){

    print(sprintf('Creating the %d map',i));     Gauslist[,,i]<-f <- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha)) }

creates 100 GaussMaps (each map is of 256*256 dim) and stores them in a matrix called Gauslist.

This process takes too long, so I was thinking if you can help me understand what should I do to make it run in parallel (in work there is a system with 16 cores).

There is mclapply (parralel version of lapply) . If I make run my code run with lapply then I will be able to run it with mclapply also (they have same syntax). If I understand it correct the sequence for doing that is to understand the following:


Can you please help me understand if my for loop can be converted to lapply or not?


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 Sat 09 Apr 2011 - 09:08: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 11 Apr 2011 - 00:50:28 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