If you modify your DESCRIPTION file by adding doMC
to the "Depends", then the "cannot find the iter function" error should go away, and functions from foreach
, iterators
and doMC
will be available when your package is loaded, which seems to be your preference. The first chapter of Writing R Extensions discusses the differences between "Imports" and "Depends". Generally, it's preferable to use "Imports" to avoid forcing users of your package to load packages that are only needed within a package, but it has uses.
Actually, the "cannot find the iter function" error that you saw is caused by a bug in the doMC
package, and using "Depends" rather than "Imports" works around this bug. Your package should only have to import packages that it directly uses, so if you don't explicitly call iter
or mclapply
, you shouldn't have to import iterators
, parallel
, or multicore
. And since parallel
has subsumed multicore
, you should never import both parallel
and multicore
, which should avoid the warning messages that you saw.
I submitted a fix for the doMC
bug to the package maintainer, so you should be able to import foreach
and doMC
into packages without an error in the next version of the package.