Learn R Programming

cards (version 0.3.0)

mock: Mock ARDs

Description

[Experimental]
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()

Value

an ARD data frame of class 'card'

Arguments

variables

(character or named list)
a character vector of variable names for functions mock_continuous(), mock_missing(), and mock_attributes().

a named list for functions mock_categorical() and mock_dichotomous(), where the list element is a vector of variable values. For mock_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

Run this code
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_fn()

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_fn(variables = c("AGE", "BMIBL"), stat_names = "sd", fmt_fn = \(x) "xx.xx") |>
  apply_fmt_fn()

Run the code above in your browser using DataLab