TmParallelApply: An OS-independent parallel version of 'lapply'

Description Usage Arguments Details Value Examples

View source: R/other_utilities.R

Description

This function takes a vector or list and a function and applies in parallel.

Usage

1
2
3
4
5
6
7
8
TmParallelApply(
  X,
  FUN,
  cpus = parallel::detectCores(),
  export = NULL,
  libraries = NULL,
  envir = parent.frame()
)

Arguments

X

A vector or list over which to apply FUN

FUN

A function to apply over X

cpus

Number of CPU cores to use, defaults to the value returned by detectCores.

export

A character vector of objects in the workspace to export when using a Windows machine. Defaults to NULL

libraries

A character vector of library/package names to load on to each cluster if using a Windows machine. Defaults to NULL

envir

Environment from which to export variables in varlist

Details

This function is used to parallelize executions in textmineR. It is necessary because of differing capabilities between Windows and Unix. Unix systems use mclapply. Windows systems use parLapply.

Value

This function returns a list of length length(X).

Examples

1
2
3
4
5
6
## Not run: 
x <- 1:10000
f <- function(y) y * y + 12
result <- TmParallelApply(x, f)

## End(Not run)

Example output

Loading required package: Matrix

Attaching package: 'textmineR'

The following object is masked from 'package:Matrix':

    update

The following object is masked from 'package:stats':

    update

sh: 1: wc: Permission denied
sh: 1: cannot create /dev/null: Permission denied

textmineR documentation built on June 28, 2021, 9:08 a.m.