'Issue parallelising loop in R
I have a function which loops through a table containing Url to data for downloading, and names that will be given to the downloaded file.
I am trying to get the following code to work in parallel - so that files are downloaded in parallel rather than sequentially- however, when the code is run it seems to do the latter. I would really appreciate any help identifying what the issue is!
library(foreach)
library(doParallel)
### Setup parallel backend to use many processors ###
cores=detectCores()
cl <- makeCluster(cores[1]-1) #not to overload your computer
registerDoParallel(cl)
### The Loop ###
foreach(i = 3:200, (nrow(Df))) %dopar% {
URL<- print(Df$Url[i])
FN<- print(Df$FileNames[i])
LOCAL<-file.path("Users/anon/desktop/books", paste(FN, ".mp4", sep=""))
download.file(URL, LOCAL, mode="wb")
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
