Skip to contents

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 is `tidytlg::roundSAS`, where
roundSAS comes from this Stack Overflow post https://stackoverflow.com/questions/12688717/round-up-from-5 * `iec`: the underlying rounding method is `round`

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 by `na_str_default`? Defaults to `TRUE`, as a way to have a different default na string behavior from the base `formatters` framework.

Value

`format_xx_fct()` format function that can be used in rtables formatting calls

See also

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)