[R] parallel processing with multiple directories

Martin Morgan mtmorgan at fhcrc.org
Tue Apr 17 22:29:02 CEST 2012


On 04/17/2012 11:06 AM, David Schaefer wrote:
> Hello,
>
> I would like to run some code in parallel with each cluster reading/writing to a different working directory.  I've tried the following code without success. The error I get is: "Error in setwd(x) : cannot change working directory"
>
> library(parallel)
> dirs<- list("out1","out2","out3")   # these directories are located within the current working directory
> temp<- 1:3
> testF<- function(x) {
>    setwd(x)
>    saveRDS(temp,"temp.drs")
>    }
> mclapply(dirs, testF)
>
> Any help would be appreciated!

Hi David,

Suppose that jobs 1 and 3 are executed on processor 2. Then after the 
first iteration the directory is ./out1 and on the second iteration 
setwd() tries to change to ./out1/out3. Full path names might help.

My unasked-for advice would be to put 'more' of the processing in testF, 
so that it is reasonable to return and then aggregate the results 
without writing to disk.

Martin

>
> --David
>
> *********************************************
> David R. Schaefer, Ph.D.
> Assistant Professor
> School of Social and Family Dynamics
> Arizona State University
> www.public.asu.edu/~schaef/
>
> ______________________________________________
> 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.


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the R-help mailing list