A function factory to generate formatting functions for value formatting that support the xx style format and control the rounding method
Usage
format_xx_fct(
roundmethod = c("sas", "iec"),
na_str_dflt = "NE",
replace_na_dflt = TRUE
)
Arguments
- roundmethod
(
string
)
choice of rounding methods. Options are:sas
: the underlying rounding method istidytlg::roundSAS
, where
roundSAS comes from this Stack Overflow post https://stackoverflow.com/questions/12688717/round-up-from-5iec
: the underlying rounding method isround
- na_str_dflt
Character to represent NA value
- replace_na_dflt
logical(1). Should an
na_string
of "NA" within the formatters framework be overridden byna_str_default
? Defaults toTRUE
, as a way to have a different default na string behavior from the baseformatters
framework.
See also
Other JJCS formats:
count_fraction
,
jjcsformat_pval_fct()
,
jjcsformat_range_fct()
Examples
jjcsformat_xx_SAS <- format_xx_fct(roundmethod = "sas")
jjcsformat_xx <- jjcsformat_xx_SAS
rcell(c(1.453), jjcsformat_xx("xx.xx"))
#> rcell: 1.45
rcell(c(), jjcsformat_xx("xx.xx"))
#> rcell:
rcell(c(1.453, 2.45638), jjcsformat_xx("xx.xx (xx.xxx)"))
#> rcell: 1.45 (2.456)