with_parallel: Turn on/off Parallel process temporarily

Description Usage Arguments Value See Also Examples

Description

Temporarily turn on/off parallel process.

Usage

1
2
3
with_parallel(new, code)

local_parallel(new = list(), .local_envir = parent.frame())

Arguments

new

[character(1)]
new parallel state: "ON" or "OFF".

code

[any]
Code to execute in the temporary environment

.local_envir

[environment]
The environment to use for scoping.

Value

[any]
The results of the evaluation of the code argument.

See Also

withr for examples

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 

with_parallel(new = "ON", {
  sprintf(
    "Parallel process is %s.",
    ifelse(parallel_is_on(), "ON", "OFF")
  )
})

with_parallel(new = "OFF", {
  sprintf(
    "Parallel process is %s.",
    ifelse(parallel_is_on(), "ON", "OFF")
  )
})

local_parallel("ON")
sprintf(
  "Parallel process is %s.",
  ifelse(parallel_is_on(), "ON", "OFF")
)
local_parallel("OFF")
sprintf(
  "Parallel process is %s.",
  ifelse(parallel_is_on(), "ON", "OFF")
)

## End(Not run)

chriszheng2016/zstmodelr documentation built on June 13, 2021, 8:59 p.m.