[R] foreach returns null first object in the list

Simon Zehnder szehnder at uni-bonn.de
Tue Sep 17 18:15:50 CEST 2013


Use an extra call to 'return()' as posted below. 

On Sep 17, 2013, at 5:55 PM, pakoun <pkount at bgc-jena.mpg.de> wrote:

> This is the output with the debugging message. I don't really understand what
> is the problem.
> 
>>  post.ls <- foreach(i =1:2, .verbose=T) %dopar% {
> +
> +              fun <- func.list[[i]]
> +              if(i==1){fun(Xa,Sa)}
> +              if(i==2){fun(Ta,Sa)}
> +
> +              }
> numValues: 2, numResults: 0, stopped: TRUE
> got results for task 1
> numValues: 2, numResults: 1, stopped: TRUE
> returning status FALSE
> got results for task 2
> numValues: 2, numResults: 2, stopped: TRUE
> calling combine function
> evaluating call object to combine results:
>  fun(accum, result.1, result.2)
> returning status TRUE
> 
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/foreach-returns-null-first-object-in-the-list-tp4676303p4676329.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.



More information about the R-help mailing list