forLoopToLapply: Transfrom For Loop To Lapply

Description Usage Arguments Details Value

Description

Determine if a for loop can be parallelized, and if so transform it into a call to lapply. This first version will modify loops if and only if the body of the loop does not do any assignments at all.

Usage

1
forLoopToLapply(forloop)

Arguments

forloop

R language object with class for.

Details

Recommended use case:

The functions in the body of the loop write to different files on each loop iteration.

The generated code WILL FAIL if:

Code in the body of the loop is truly iterative. Functions update global state in any way other than direct assignment.

Value

call R call to parallel::mclapply if successful, otherwise the original forloop.


makeParallel documentation built on May 2, 2019, 9:40 a.m.