future()
:s are resolved,
e.g. by eager or by lazy evaluation.plan(strategy = NULL, ..., substitute = TRUE, .call = TRUE)
strategy
expression is
substitute()
:d, otherwise not.eager
, which can be set by
option future.plan
and, if that is not set,
system environment variable R_FUTURE_PLAN
.
To reset the strategy back to the default, use plan("default")
.eager()
,
lazy()
and multicore()
.
Other package may provide additional evaluation strategies/functions.a <- b <- c <- NA_real_
# A lazy future
plan(lazy)
f <- future({
a <- 7
b <- 3
c <- 2
a * b * c
})
y <- value(f)
print(y)
str(list(a=a, b=b, c=c)) ## All NAs
# An eager future
plan(eager)
f <- future({
a <- 7
b <- 3
c <- 2
a * b * c
})
y <- value(f)
print(y)
str(list(a=a, b=b, c=c)) ## All NAs
# A multicore future
plan(multicore)
f <- future({
a <- 7
b <- 3
c <- 2
a * b * c
})
y <- value(f)
print(y)
str(list(a=a, b=b, c=c)) ## All NAs
## Multisession futures gives an error on R CMD check on
## Windows (but not Linux or OS X) for unknown reasons.
## The same code works in package tests.
# A multisession future
plan(multisession)
f <- future({
a <- 7
b <- 3
c <- 2
a * b * c
})
y <- value(f)
print(y)
str(list(a=a, b=b, c=c)) ## All NAs
Run the code above in your browser using DataLab