Dear R users,

I have created a package and would like to check it for CRAN/R-Forge submission. I use some parallelized code with the help of foreach and doMC.

R CMD check now gives me a warning even though my code is correctly programmed (at least I think that it is). The following dummy function inside a package produces the error:


dummy = function() {


dummyfun = function(iter) {
iter * 2
}
registerDoMC(4)
results = foreach(i = 1:10) %dopar% dummyfun(iter = i)
}


R CMD check --as-cran mypackage

now gives:

dummy: no visible binding for global variable ā€˜i’


It is clear that i can not be found as only the call to foreach creates it (similar to a for loop), but should not the R check consider this? Or is my programming poor? Setting i to any arbitrary value before running foreach makes the error disappear, but this would feel as a really dirty hack.


Cheers
Jannis

______________________________________________
R-help@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.

Reply via email to