mcReplicate | R Documentation |
Multi-core replicate. Use multiple cores for repeated evaluation of an expression.
mcReplicate(n, expr, mc.cores = 4, refresh = 0.1)
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. |
A vector, matrix, or list of length 'n'.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.