[R] multi process support in R
Alaios
alaios at yahoo.com
Mon Mar 28 16:45:29 CEST 2011
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
--- On Thu, 2/17/11, Ben Haller <rhelp at sticksoftware.com> wrote:
> From: Ben Haller <rhelp at sticksoftware.com>
> Subject: Re: [R] multi process support in R
> To: "Alaios" <alaios at 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
>
>
>
More information about the R-help
mailing list