insightsengineering / formatters

A framework for creating listings of raw data that include specialized formatting, headers, footers, referential footnotes, and pagination.
https://insightsengineering.github.io/formatters/
Other
15 stars 6 forks source link

Feature: when formatting function has na_str as function argument, allow format_value to pass this argument #319

Open iaugusty opened 1 week ago

iaugusty commented 1 week ago

Summary We'd like to use NE as our default na_str character, in combination with a formatting function, rather than the built-in character string formats.

On the other hand, we want to maintain consistent approach in switching to another na_str character in rtables layouts, eg pass the parameter na_str into an analyze call.

eg

custom_fmt_function <- function(xxx, .na_str = "NE") {
 mainfun <- function(x, output, na_str = .na_str){}
mainfun
}

analyze(vars = "VAR",
.stats = "mystat",
.formats = c( "mystat" = custom_fmt_function(xxx)),
na_str = "ne")

rather than 

analyze(vars = "VAR",
.stats = "mystat",
.formats = c( "mystat" = custom_fmt_function(xxx, .na_str = "ne"))
Melkiades commented 1 day ago

I think this is a relevant update and we should unify our behavior in someway