Multi-core replicate. Use multiple cores for repeated evaluation of an expression.
mcReplicate.Rd
Multi-core replicate. Use multiple cores for repeated evaluation of an expression.
Arguments
- n
integer; the number of replications.
- expr
the expression (a language object, usually a call) to evaluate n times.
- mc.cores
number of cores to use.
- refresh
status update refresh interval.
Examples
one_sim = \(n = 100, control_prob = 0.1, rel_effect = 0.01) {
treat_prob = control_prob + (control_prob * rel_effect)
cy = rbinom(n = n, size = 1, prob = control_prob)
ty = rbinom(n = n, size = 1, prob = treat_prob)
mean(ty) - mean(cy)
}
mcReplicate(10, one_sim(), mc.cores = 2)
#>
#> [1] 0.08 0.01 0.03 0.01 -0.01 0.07 0.02 -0.03 -0.03 0.02