Adds a table/listing or figure type to the dispatcher, or replaces an existing one. This lets an organization add study-specific outputs that run through the same renderers.
Arguments
- type
Type key, for example
"vitals".- fun
For tables:
function(data, opts, config), wheredatais a named list of data frames; it must return atlf_table_result(), a data frame, a gtsummary table or a cardscard(seeas_tlf_table()). For figures:function(df, ctx, opts, config); it must return a ggplot.- label
Human-readable label, for example for a selection menu.
- class
For tables:
"Table"or"Listing".- domains
Names of the
dataelements the builder reads.- kind
Which registry to remove
typefrom.
Examples
tlf_register_table("n_by_arm", function(data, opts, config) {
n <- stat_big_n(data$adsl, "TRT01A")
tlf_table_result(data.frame(Group = names(n), N = as.character(n)))
}, label = "Subjects by arm", domains = "adsl")
tlf_build_table("n_by_arm", list(adsl = ex_adsl))
#> <tlf_table> 4 row(s) x 2 column(s)
#> Group N
#> Drug 10 mg 20
#> Drug 20 mg 20
#> Placebo 20
#> Total 60
tlf_unregister("n_by_arm")