RepParallel: Parallel version of 'replicate'

Description Usage Arguments Value Implementation Author(s) See Also

Description

A simple parallel clone of replicate; this function is a wrapper for mclapply just like replicate is a wrapper for sapply.

Usage

1
RepParallel(n, expr, simplify = "array",...)

Arguments

n

An integer giving the number of replications to execute.

expr

R code to execute.

simplify

logical or character string; should the result be simplified to a vector, matrix or higher dimensional array if possible?

...

Optional arguments to mclapply.

Value

Just as in replicate.

Implementation

1
2
3
4
5
6
7
8
<<*>>=
    RepParallel <- function(n, expr, simplify = "array",...) {
      answer <-
        mclapply(integer(n), eval.parent(substitute(function(...) expr)),...)
      if (!identical(simplify, FALSE) && length(answer)) 
        return(simplify2array(answer, higher = (simplify == "array")))
      else return(answer)
    }

Author(s)

Gray Calhoun gcalhoun@iastate.edu

See Also

replicate, mclapply


grayclhn/dbframe-R-library documentation built on May 17, 2019, 8:33 a.m.