R run 2 different blocks of code at the same time (in parallel)
r
Solution
You could try substituting/quoting the functions then evaluating them in parallel.
library(parallel)
ExpressionVect <- c(substitute(function1()),
substitute(function2()))
mclapply(ExpressionVect, eval, mc.cores= 2)
This allows the functions to be evaluated in parallel when they are independent functions
Problem
Is there a way to run 2 different blocks of code at the same time. I have been looking at parallel packages within R and they all appear to be based on running the same function in a loop. I am looking for a way to run different functions at the same time (1 iteration of the loop). For example, I would like to create a model on a certain data object at the same time as creating another model on a different object. I could do this by starting another instance of R but would rather keep it all in the same script. Is this possible? I appreciate any advice.