Learn R Programming

mcreplicate (version 0.1.1)

mc_replicate: Multi-core replicate.

Description

Multi-core replicate.

Usage

mc_replicate(n, expr, refresh = 0.1, mc.cores = 2)

Arguments

n

integer: the number of replications.

expr

the expression (a language object, usually a call) to evaluate repeatedly.

refresh

status update refresh interval

mc.cores

number of cores to use

Value

A vector, matrix, or list of length n.

Examples

Run this code
# NOT RUN {
one_sim <- function(n, control_prob, rel_effect) {
  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)
  }

  mc_replicate(10, one_sim(n = 100, control_prob = 0.1, rel_effect = 0.01))

# }

Run the code above in your browser using DataLab