Format numeric values to print with a specified number of significant figures.
format_sigfig(sigfig, format = "xx", num_fmt = "fg")(integer(1))
number of significant figures to display.
(string)
the format label (string) to apply when printing the value. Decimal
places in string are ignored in favor of formatting by significant figures. Formats options are:
"xx", "xx / xx", "(xx, xx)", "xx - xx", and "xx (xx)".
(string)
numeric format modifiers to apply to the value. Defaults to "fg" for
standard significant figures formatting - fixed (non-scientific notation) format ("f")
and sigfig equal to number of significant figures instead of decimal places ("g"). See the
formatC() format argument for more options.
An rtables formatting function.
Other formatting functions:
extreme_format,
format_auto(),
format_count_fraction(),
format_count_fraction_fixed_dp(),
format_count_fraction_lt10(),
format_extreme_values(),
format_extreme_values_ci(),
format_fraction(),
format_fraction_fixed_dp(),
format_fraction_threshold(),
format_xx(),
formatting_functions
fmt_3sf <- format_sigfig(3)
fmt_3sf(1.658)
#> [1] "1.66"
fmt_3sf(1e1)
#> [1] "10.0"
fmt_5sf <- format_sigfig(5)
fmt_5sf(0.57)
#> [1] "0.57000"
fmt_5sf(0.000025645)
#> [1] "0.000025645"