withOptions
From R.utils v1.32.4
by Henrik Bengtsson
Evaluate an R expression with options set temporarily
Evaluate an R expression with options set temporarily.
- Keywords
- programming, IO
Usage
withOptions(expr, ..., args=list(), envir=parent.frame())
Arguments
- expr
- The R expression to be evaluated.
- ...
- Named options to be used.
- args
- (optional) Additional named options specified as a named
list
. - envir
- The
environment
in which the expression should be evaluated.
Value
- Returns the results of the expression evaluated.
See Also
Internally, eval
() is used to evaluate the expression.
and options
() to set graphical parameters.
Examples
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)
Community examples
Looks like there are no examples yet.