export {job} | R Documentation |
What to return from a job
Description
Call this function as the last line in job::job()
to select what is exported
back into globalenv()
. export()
does nothing if called in any other context.
Usage
export(value = "changed", file = NULL)
Arguments
value |
What to return. One of:
|
file |
Name of |
Details
Under the hood, this function merely rm()
variables that does not match value
.
Because job::job()
returns everything at the end of the script, this defines
what is returned.
Value
NULL
invisibly.
Author(s)
Jonas Kristoffer Lindeløv, jonas@lindeloev.dk
Examples
if (rstudioapi::isAvailable()) {
a = 55
b = 77
d = 88
job::job({n = 11; a = 55; job::export("all")}) # export a, b, d, n
job::job({n = 11; a = 11; job::export("changed")}) # export a, n
job::job({n = 11; a = 11; job::export("new")}) # export n
job::job({n = 11; a = 55; job::export(c(a, d, b))}) # export a, d, b
job::job({n = 11; a = 55; job::export("none")}) # export nothing
# To file
job::job({n = 11; a = 11; job::export("changed", file = "jobresult.RData")}) # save a, n
jobresult = new.env() # import to this env instead of global
load("jobresult.RData", envir = jobresult)
print(jobresult$n)
}