insightsengineering / cards

CDISC Analysis Results Data
https://insightsengineering.github.io/cards/
30 stars 2 forks source link

BUG: Issue applying the formatting function #177

Closed ddsjoberg closed 7 months ago

ddsjoberg commented 7 months ago

In the example below, I am specifying a non-default formatting function for p25. But it's not formatting as expected.

cards::ard_continuous(
  gtsummary::trial, 
  variables = age,
  fmt_fn = list(age = list(p25 = \(x) round(x, 2) |> as.character()))
) |> 
  cards::apply_statistic_fmt_fn() |> 
  dplyr::filter(stat_name %in% "p25") |> 
  as.data.frame()
#>   variable    context stat_name      stat_label statistic statistic_fmt
#> 1      age continuous       p25 25th Percentile        38            38
#>                           statistic_fmt_fn warning error
#> 1 function (x) , as.character(round(x, 2))    NULL  NULL

round(pi, 2) |> as.character()
#> [1] "3.14"

Created on 2024-02-15 with reprex v2.1.0

ddsjoberg commented 7 months ago

oy never mind!