Set the default rounding specification used by periglue functions
Source:R/set_default_rounding_spec.R
set_default_rounding_spec.RdStores a rounding_specification object as the session-wide default used
by peri_glue() and peri_value() when no rspec argument is supplied.
This is an alternative to setting individual periglue.* options by hand.
Pass NULL to clear the stored default and revert to factory settings.
Arguments
- rspec
a
rounding_specificationobject created withround_spec(), orNULLto clear the current default.
Value
invisibly returns the previous default rounding specification, or
NULL if none was set. This makes it easy to save and restore:
old <- set_default_rounding_spec(new_spec).
Examples
# Set a custom default
rspec <- round_spec() |> round_using_decimal(digits = 3)
set_default_rounding_spec(rspec)
# peri_* functions now use this spec without needing rspec = ...
peri_value(pi)
#> [1] "3.142"
# Clear the default to revert to factory settings
set_default_rounding_spec(NULL)
peri_value(pi)
#> [1] "3.1"