Setting and resetting options is lengthy in command mode. WithOptions()
allows to evaluate a function with temporary set options.
WithOptions(optlist, expr)
Arguments
- optlist
a list with new option settings.
- expr
the expression to be evaluated
Value
the function result
Author
Thomas Lumley <t.lumley@auckland.ac.nz>
Examples
# original:
print((1:10)^-1)
#> [1] 1.000 0.500 0.333 0.250 0.200 0.167 0.143 0.125 0.111 0.100
# with new options
WithOptions(list(digits=3), print((1:10)^-1))
#> [1] 1.000 0.500 0.333 0.250 0.200 0.167 0.143 0.125 0.111 0.100