execute_parallel: Execute f in parallel partitioned by partition_column.

Description Usage Arguments Value See Also Examples

View source: R/partition_tables.R

Description

Execute f in parallel partitioned by partition_column, see partition_tables for details.

Usage

1
2
3
4
5
6
7
8
9
execute_parallel(
  tables,
  f,
  partition_column,
  ...,
  cl = NULL,
  debug = FALSE,
  env = parent.frame()
)

Arguments

tables

named map of tables to use.

f

function to apply to each tableset signature is function takes a single argument that is a named list of data.frames.

partition_column

character name of column to partition on

...

force later arguments to bind by name.

cl

parallel cluster.

debug

logical if TRUE use lapply instead of parallel::clusterApplyLB.

env

environment to look for values in.

Value

list of f evaluations.

See Also

partition_tables

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
if(requireNamespace("parallel", quietly = TRUE)) {
  cl <- parallel::makeCluster(2)

  d <- data.frame(x = 1:5, g = c(1, 1, 2, 2 ,2))
  f <- function(dl) {
    d <- dl$d
    d$s <- sqrt(d$x)
    d
  }
  r <- execute_parallel(list(d = d), f,
                        partition_column = "g",
                        cl = cl) %.>%
    do.call(rbind, .) %.>%
    print(.)

  parallel::stopCluster(cl)
}

WinVector/wrapr documentation built on Nov. 21, 2020, 8:31 p.m.