[R] parallel processing with multiple directories
Petr Savicky
savicky at cs.cas.cz
Tue Apr 17 21:50:03 CEST 2012
On Tue, Apr 17, 2012 at 11:06:05AM -0700, 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)
Hi.
Try to include
print(getwd())
to testF() function, so that you see, where the script is running.
Another option is not to use setwd() and use
saveRDS(temp, paste(x, "temp.drs", sep="/"))
instead of saveRDS(temp,"temp.drs").
Hope this helps.
Petr Savicky.
More information about the R-help
mailing list