Re: [R] multi process support in R

From: Alaios <alaios_at_yahoo.com>
Date: Mon, 28 Mar 2011 07:45:29 -0700 (PDT)


Dear all,
I would like to ask your help of how I can convert the loop below to a mclapply (this is the apply to many cores)

 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[findC(c(i,j),sr)[1],findC(c(i,j),sr)[2]  ]<-fxy(c(i,j))
      }

    }
lst[[i,j]] <-estimatedsr

What the loop above does is that calculates a value and then saves it inside the lst matrix.

I am not sure how I should convert this process to run with many cores. What confuses me that my in this code one should track the i,j values so each cores saves at the right place inside the lst matrix.

Could you please help me with that?
Regards
Alex

> From: Ben Haller <rhelp_at_sticksoftware.com>
> Subject: Re: [R] multi process support in R
> To: "Alaios" <alaios@yahoo.com>
> Cc: R-help_at_r-project.org
> Date: Thursday, February 17, 2011, 10:47 AM
> On Feb 17, 2011, at 11:40 AM, Alaios
> wrote:
>
> > ...Is it possible to split work in many cores in R and
> if yes how is this library called?
>
>   I'd recommend the "mclapply" function in the
> "multicore" package.  The only drawback is that you
> can't run your code in a GUI any more.
>
> Ben Haller
> McGill University
>
>
>



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 28 Mar 2011 - 14:49:17 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 28 Mar 2011 - 14:50:24 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