Learn R Programming

doRedis (version 2.0.0)

setExport: Manually add symbol names to the worker environment export list.

Description

The setExport function lets users manually declare symbol names of corresponding objects that should be exported to workers.

Usage

setExport(names = c())

Arguments

names

A character vector of symbol names to export.

Value

names is invisibly returned.

Details

The foreach function includes a similar .export parameter.

We provide this supplemental export option for users without direct access to the foreach function, for example, when foreach is used inside another package.

Examples

Run this code
# NOT RUN {
require("doRedis")
registerDoRedis("work queue")
startLocalWorkers(n=1, queue="work queue")

f <- function() pi

foreach(1) %dopar% eval(call("f"))
# Returns the error:
# Error in eval(call("f")) : task 1 failed - could not find function "f"

# Manuall export the symbol f:
setExport("f")
foreach(1) %dopar% eval(call("f"))
# Ok then.
#[[1]]
#[1] 3.141593
removeQueue("work queue")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab