1

I have a parallelized code in R that uses foreach()

ls<-foreach(reps = 1:1000) %dopar% {
....

For each loop I would like to load a different dataset, ideally:

ls<-foreach(reps = 1:1000) %dopar% {
name<-paste0("dataset",reps,'.Rdata',sep="",collapse=NULL)
load(name)
...

So I would like to use the "reps" index of foreach which goes from 1:1000 and load each dataset (dataset1, dataset2...dataset1000) in each iteration of the loop.

Is this possible to do somehow?

user1723765
  • 6,179
  • 18
  • 57
  • 85
  • If all your datasets are in the same directory, there are more efficient and simpler to implement methods. See: http://www.r-bloggers.com/merge-all-files-in-a-directory-using-r-into-a-single-dataframe/ or http://stackoverflow.com/questions/11433432/importing-multiple-csv-files-into-r – Phil May 22 '15 at 10:23
  • Your example looks good. Did you have a problem with it? – Steve Weston May 22 '15 at 13:17

0 Answers0