Create empty ARDs used to create mock tables or table shells.
Where applicable, the formatting functions are set to return 'xx' or 'xx.x'.
Usage
mock_categorical(
variables,
statistic = everything() ~ c("n", "p", "N"),
by = NULL
)
mock_continuous(
variables,
statistic = everything() ~ c("N", "mean", "sd", "median", "p25", "p75", "min", "max"),
by = NULL
)
mock_dichotomous(
variables,
statistic = everything() ~ c("n", "p", "N"),
by = NULL
)
mock_missing(
variables,
statistic = everything() ~ c("N_obs", "N_miss", "N_nonmiss", "p_miss", "p_nonmiss"),
by = NULL
)
mock_attributes(label)
mock_total_n()Arguments
- variables
(
characteror namedlist)
a character vector of variable names for functionsmock_continuous(),mock_missing(), andmock_attributes().a named list for functions
mock_categorical()andmock_dichotomous(), where the list element is a vector of variable values. Formock_dichotomous(), only a single value is allowed for each variable.- statistic
(
formula-list-selector)
a named list, a list of formulas, or a single formula where the list elements are character vectors of statistic names to appear in the ARD.- by
(named
list)
a named list where the list element is a vector of variable values.- label
(named
list)
named list of variable labels, e.g.list(cyl = "No. Cylinders").
Examples
mock_categorical(
variables =
list(
AGEGR1 = factor(c("<65", "65-80", ">80"), levels = c("<65", "65-80", ">80"))
),
by = list(TRTA = c("Placebo", "Xanomeline High Dose", "Xanomeline Low Dose"))
) |>
apply_fmt_fun()
#> # An ARD data frame: 27 × 12
#> group1 group1_level variable variable_level context stat_name stat stat_fmt
#> <chr> <list> <chr> <list> <chr> <chr> <list> <list>
#> 1 TRTA Placebo AGEGR1 <65 catego… n <NULL> xx
#> 2 TRTA Placebo AGEGR1 <65 catego… p <NULL> xx.x
#> 3 TRTA Placebo AGEGR1 <65 catego… N <NULL> xx
#> 4 TRTA Placebo AGEGR1 65-80 catego… n <NULL> xx
#> 5 TRTA Placebo AGEGR1 65-80 catego… p <NULL> xx.x
#> 6 TRTA Placebo AGEGR1 65-80 catego… N <NULL> xx
#> 7 TRTA Placebo AGEGR1 >80 catego… n <NULL> xx
#> 8 TRTA Placebo AGEGR1 >80 catego… p <NULL> xx.x
#> 9 TRTA Placebo AGEGR1 >80 catego… N <NULL> xx
#> 10 TRTA Xanomeline … AGEGR1 <65 catego… n <NULL> xx
#> # ℹ 17 more rows
#> # ℹ 4 more variables: stat_label <chr>, fmt_fun <list>, warning <list>,
#> # error <list>
mock_continuous(
variables = c("AGE", "BMIBL"),
by = list(TRTA = c("Placebo", "Xanomeline High Dose", "Xanomeline Low Dose"))
) |>
# update the mock to report 'xx.xx' for standard deviations
update_ard_fmt_fun(variables = c("AGE", "BMIBL"), stat_names = "sd", fmt_fun = \(x) "xx.xx") |>
apply_fmt_fun()
#> # An ARD data frame: 48 × 11
#> group1 group1_level variable context stat_name stat_label stat stat_fmt
#> <chr> <list> <chr> <chr> <chr> <chr> <list> <list>
#> 1 TRTA Placebo AGE continuous N N <NULL> xx
#> 2 TRTA Placebo AGE continuous mean Mean <NULL> xx.x
#> 3 TRTA Placebo AGE continuous sd SD <NULL> xx.xx
#> 4 TRTA Placebo AGE continuous median Median <NULL> xx.x
#> 5 TRTA Placebo AGE continuous p25 Q1 <NULL> xx.x
#> 6 TRTA Placebo AGE continuous p75 Q3 <NULL> xx.x
#> 7 TRTA Placebo AGE continuous min Min <NULL> xx.x
#> 8 TRTA Placebo AGE continuous max Max <NULL> xx.x
#> 9 TRTA Placebo BMIBL continuous N N <NULL> xx
#> 10 TRTA Placebo BMIBL continuous mean Mean <NULL> xx.x
#> # ℹ 38 more rows
#> # ℹ 3 more variables: fmt_fun <list>, warning <list>, error <list>
