setExport | R Documentation |
The setExport function lets users manually declare symbol names of corresponding objects that should be exported to workers.
setExport(names = c())
names |
A character vector of symbol names to export. |
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.
The value of names
is invisibly returned (this function is used ofr its side effect).
## Not run:
registerDoRedis("work queue")
startLocalWorkers(n=1, queue="work queue", linger=1)
f <- function() pi
(foreach(1) %dopar% tryCatch(eval(call("f")), error = as.character))
# Returns the error converted to a message:
# Error in eval(call("f")) : task 1 failed - could not find function "f"
# Manually export the symbol f:
setExport("f")
(foreach(1) %dopar% eval(call("f")))
# Now f is found.
removeQueue("work queue")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.