Compute Analysis Results Data (ARD) for statistics related to data missingness.

ard_missing(data, ...)

# S3 method for class 'data.frame'
ard_missing(
  data,
  variables,
  by = dplyr::group_vars(data),
  statistic = everything() ~ c("N_obs", "N_miss", "N_nonmiss", "p_miss", "p_nonmiss"),
  fmt_fun = NULL,
  stat_label = everything() ~ default_stat_labels(),
  fmt_fn = deprecated(),
  ...
)

Arguments

data

(data.frame)
a data frame

...

Arguments passed to methods.

variables

(tidy-select)
columns to include in summaries.

by

(tidy-select)
results are tabulated by all combinations of the columns specified.

statistic

(formula-list-selector)
a named list, a list of formulas, or a single formula where the list element is a named list of functions (or the RHS of a formula), e.g. list(mpg = list(mean = \(x) mean(x))).

The value assigned to each variable must also be a named list, where the names are used to reference a function and the element is the function object. Typically, this function will return a scalar statistic, but a function that returns a named list of results is also acceptable, e.g. list(conf.low = -1, conf.high = 1). However, when errors occur, the messaging will be less clear in this setting.

fmt_fun

(formula-list-selector)
a named list, a list of formulas, or a single formula where the list element is a named list of functions (or the RHS of a formula), e.g. list(mpg = list(mean = \(x) round(x, digits = 2) |> as.character())).

stat_label

(formula-list-selector)
a named list, a list of formulas, or a single formula where the list element is either a named list or a list of formulas defining the statistic labels, e.g. everything() ~ list(mean = "Mean", sd = "SD") or everything() ~ list(mean ~ "Mean", sd ~ "SD").

fmt_fn

[Deprecated]

Value

an ARD data frame of class 'card'

Examples

ard_missing(ADSL, by = "ARM", variables = "AGE")
#> # An ARD data frame: 15 × 10
#>    group1 group1_level       variable context stat_name stat_label  stat fmt_fun
#>    <chr>  <list>             <chr>    <chr>   <chr>     <chr>      <lis> <list> 
#>  1 ARM    Placebo            AGE      missing N_obs     Vector Le…    86 0      
#>  2 ARM    Placebo            AGE      missing N_miss    N Missing      0 0      
#>  3 ARM    Placebo            AGE      missing N_nonmiss N Non-mis…    86 0      
#>  4 ARM    Placebo            AGE      missing p_miss    % Missing      0 <fn>   
#>  5 ARM    Placebo            AGE      missing p_nonmiss % Non-mis…     1 <fn>   
#>  6 ARM    Xanomeline High D… AGE      missing N_obs     Vector Le…    84 0      
#>  7 ARM    Xanomeline High D… AGE      missing N_miss    N Missing      0 0      
#>  8 ARM    Xanomeline High D… AGE      missing N_nonmiss N Non-mis…    84 0      
#>  9 ARM    Xanomeline High D… AGE      missing p_miss    % Missing      0 <fn>   
#> 10 ARM    Xanomeline High D… AGE      missing p_nonmiss % Non-mis…     1 <fn>   
#> 11 ARM    Xanomeline Low Do… AGE      missing N_obs     Vector Le…    84 0      
#> 12 ARM    Xanomeline Low Do… AGE      missing N_miss    N Missing      0 0      
#> 13 ARM    Xanomeline Low Do… AGE      missing N_nonmiss N Non-mis…    84 0      
#> 14 ARM    Xanomeline Low Do… AGE      missing p_miss    % Missing      0 <fn>   
#> 15 ARM    Xanomeline Low Do… AGE      missing p_nonmiss % Non-mis…     1 <fn>   
#> # ℹ 2 more variables: warning <list>, error <list>

ADSL |>
  dplyr::group_by(ARM) |>
  ard_missing(
    variables = "AGE",
    statistic = ~"N_miss"
  )
#> # An ARD data frame: 3 × 10
#>   group1 group1_level        variable context stat_name stat_label  stat fmt_fun
#>   <chr>  <list>              <chr>    <chr>   <chr>     <chr>      <lis>  <list>
#> 1 ARM    Placebo             AGE      missing N_miss    N Missing      0       0
#> 2 ARM    Xanomeline High Do… AGE      missing N_miss    N Missing      0       0
#> 3 ARM    Xanomeline Low Dose AGE      missing N_miss    N Missing      0       0
#> # ℹ 2 more variables: warning <list>, error <list>