foreach() with 'lapply'?
On Thu, 2011-07-21 at 10:27 -0700, Megh Dal wrote:
Dear all, I was exploring the "dopar" mechanism in foreach package, however it seems that "dopar" can be applied only in place of 'for' loop. Here my question is: can it be used with 'lapply' construct? I have a big 'list' object and I am in some process to apply some complex custom made function on each element of that 'list' object. I have dual core windows vista system, and planning to break that list into 2 part of equal length, then apply that function simultaneously using both cores. Can somebody throw some light how to achieve that?
Please read the documentation before posting. foreach iterates over some iterator, as described in the package vignette here: http://cran.r-project.org/web/packages/foreach/vignettes/foreach.pdf and that iterator may easily be a list. In that case, foreach looks very much like lapply. foreach will also, by default, return a list. See the documentation for .combine. If you need additional help, please provide a minimal self-contained example, per the posting guide. Regards, - Brian
Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock