Where is the assignment that creates the "Data" object that isn't found?
Does it happen within one of the sourced scripts? Or, alternatively, does
it happen prior to the foreach() loop? If it's the latter, I expect you
just need to use the ".export" argument in the foreach().

-Jonathan



-------------------------------------------------------------------------
J.P. Olmsted

029 Corwin (Office)
130 Corwin Hall (Mail)

Politics Department
Princeton University
Princeton, NJ 08544


t: 609.258.6202
f: 609.258.1110
jolmsted@princeton.edu
http://about.me/olmjo
-------------------------------------------------------------------------


On Sun, Dec 15, 2013 at 1:05 PM, Jim Maas <jimmaasuk@gmail.com> wrote:

> I've use open mpi, doMPI and foreach quite a bit, although I'm no expert.
>  Recently I've been attempting to help a friend parallelize some loops that
> contain a "source" function to an external .R code file.  I get some
> strange behaviour, when I use %do% it executes and walks through the code
> nicely, however when I change to %dopar% I get  this error.
>
> Error in { : task 2 failed - "object 'Data' not found"
>
> The file being sourced is large and I have tried many things but can not
> make it work.  Do foreach and source not play well together?  Here is a
> copy of the foreach loop, any thoughts and/or suggestions most welcome.
>  I've spent hours on it and tried everything I can think of .
>
> Thanks
>
> J
>
> ====================================
> newstuff <- foreach (k=1:length(CountryFileList), .packages = c("Hmisc",
> "gtools"),
>                      .combine = rbind)  %dopar% {
>
>                           setwd("/home/jamaas/NewRun/DataNoProblems")
>                           print(CountryFileList[k])
>                           CountryFile = CountryFileList[k]
>
> load(paste(CountryFile,"NoProblems.RData",sep=""))
>                           TextFileName = 0
>                           setwd("/home/jamaas/Rcode/Nate/Treatment0")
>                           source(RegressionScript)
>                           Output
> }
>
> --
> Jim Maas
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-hpc mailing list
> R-sig-hpc@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
>

	[[alternative HTML version deleted]]

