Closed kaipingyang closed 1 month ago
Thanks @kaipingyang for this. In principles, you should be able to achieve that and you should also be able to modify multiple values. Here the fixed behavior in a {rtables} example:
library(rtables)
#> Loading required package: formatters
#>
#> Attaching package: 'formatters'
#> The following object is masked from 'package:base':
#>
#> %||%
#> Loading required package: magrittr
#>
#> Attaching package: 'rtables'
#> The following object is masked from 'package:utils':
#>
#> str
my_fun <- function(x, ...) {
rcell(c(1, NA, NA), format = "xx.x (xx.x - xx.x)", format_na_str = c("NE", "NU"))
}
basic_table() |>
analyze("A", afun = my_fun, format = "xx - xx") |>
build_table(tibble::tibble("A" = NA))
#> all obs
#> ——————————————————————
#> my_fun 1.0 (NE - NU)
Created on 2024-08-07 with reprex v2.1.1
Summary
For formatters v0.5.8:
format_value
cannot always correctly handle custom strings that are displayed when the value of x is missing For examples, when I set format = "xx.x (xx.x - xx.x)" and na_str = "NE", abc doesn't always get "NE".R session info
OS