Last chance! 50% off unlimited learning
Sale ends in
withOptions(expr, ..., args=list(), envir=parent.frame())
list
.environment
in which the expression should be evaluated.expr
will also be undone upon exit.
eval
() is used to evaluate the expression.
and options
() to set options.
print(pi)
# Same, i.e. using default
withOptions({
print(pi)
})
# Printing with two digits
withOptions({
print(pi)
}, digits=2)
# Printing with two digits then with three more
withOptions({
print(pi)
withOptions({
print(pi)
}, digits=getOption("digits")+3)
}, digits=2)
# Still printing with the default
print(pi)
Run the code above in your browser using DataLab