Hello Michael,
thanks for the answer, it looks like that the foreach package might do what I 
want. Few comments though

The foreach loop asks for a way to combine results, which I do not want to have 
any. AFter I load a dataset the subsequent function does plotting and save the 
files as pdfs, nothing more.

What is the difference between %do% and %dopar%, they look actually the same.

I do not see to be anyway to contol the number of used cores, like set to use 
only 4, or 8 or 16.

Regards
Alex



________________________________
 From: R. Michael Weylandt <michael.weyla...@gmail.com>

Cc: R help <R-help@r-project.org> 
Sent: Tuesday, May 15, 2012 8:00 AM
Subject: Re: [R] Simple parallel for loop

Take a look at foreach() and %dopar$ from the CRAN package foreach.

Michael


> 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@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.
>
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to