[R] Simple parallel for loop
R. Michael Weylandt
michael.weylandt at gmail.com
Tue May 15 08:00:13 CEST 2012
Take a look at foreach() and %dopar$ from the CRAN package foreach.
Michael
On Tue, May 15, 2012 at 1:57 AM, Alaios <alaios at yahoo.com> wrote:
> Dear all,
> I am having a for loop that iterates a given number of measurements that I would like to split over 16 available cores. The code is in the following format
>
> inputForFunction<-expand.grid(caseList,filterList)
> for (i in c(1:length(inputForFunction$Var1))){#
> FileList<-GetFileList(flag=as.vector(inputForFunction$Var1[i]));
> print(sprintf("Calling the plotsCreate for %s and%s",as.vector(inputForFunction$Var1[i]),as.vector(inputForFunction$Var2[i])))
>
> plotsCreate(Folder=mainFolder,case=as.vector(inputForFunction$Var1[i]),DataList=FileList,DataFilter=as.vector(inputForFunction$Var2[i]))
> }
>
> as you can see after the inputForFunction is calculated then my code iterates over the available combinations of caseList and filterList. It would be great, without major changes, split these "tasks" to all the available processors.
>
> Is there some way to do that?
>
> Regards
> Alex
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list