Skip to contents

Stack multiple ARD calls sharing common input data and by variables. Optionally incorporate additional information on represented variables, e.g. overall calculations, rates of missingness, attributes, or transform results with shuffle_ard().

If the ard_stack(by) argument is specified, a univariate tabulation of the by variable will also be returned.

Usage

ard_stack(
  data,
  ...,
  .by = NULL,
  .overall = FALSE,
  .missing = FALSE,
  .attributes = FALSE,
  .total_n = FALSE,
  .shuffle = FALSE
)

Arguments

data

(data.frame)
a data frame

...

(dynamic-dots)
Series of ARD function calls to be run and stacked

.by

(tidy-select)
columns to tabulate by in the series of ARD function calls

.overall

(logical)
logical indicating whether overall statistics should be calculated (i.e. re-run all ard_*() calls with by=NULL). Default is FALSE.

.missing

(logical)
logical indicating whether to include the results of ard_missing() for all variables represented in the ARD. Default is FALSE.

.attributes

(logical)
logical indicating whether to include the results of ard_attributes() for all variables represented in the ARD. Default is FALSE.

.total_n

(logical)
logical indicating whether to include of ard_total_n() in the returned ARD.

.shuffle

(logical)
logical indicating whether to perform shuffle_ard() on the final result. Default is FALSE.

Value

a transformed ARD data frame (of class 'card' if .shuffle = FALSE)

Examples

ard_stack(
  data = ADSL,
  ard_categorical(variables = "AGEGR1"),
  ard_continuous(variables = "AGE"),
  .by = "ARM",
  .overall = TRUE,
  .attributes = TRUE
)
#> {cards} data frame: 83 x 11
#>    group1 group1_level variable variable_level stat_name stat_label  stat
#> 1     ARM      Placebo   AGEGR1          65-80         n          n    42
#> 2     ARM      Placebo   AGEGR1          65-80         N          N    86
#> 3     ARM      Placebo   AGEGR1          65-80         p          % 0.488
#> 4     ARM      Placebo   AGEGR1            <65         n          n    14
#> 5     ARM      Placebo   AGEGR1            <65         N          N    86
#> 6     ARM      Placebo   AGEGR1            <65         p          % 0.163
#> 7     ARM      Placebo   AGEGR1            >80         n          n    30
#> 8     ARM      Placebo   AGEGR1            >80         N          N    86
#> 9     ARM      Placebo   AGEGR1            >80         p          % 0.349
#> 10    ARM    Xanomeli…   AGEGR1          65-80         n          n    55
#>  73 more rows
#>  Use `print(n = ...)` to see more rows
#>  4 more variables: context, fmt_fn, warning, error

ard_stack(
  data = ADSL,
  ard_categorical(variables = "AGEGR1"),
  ard_continuous(variables = "AGE"),
  .by = "ARM",
  .shuffle = TRUE
)
#> # A tibble: 60 × 6
#>    ARM                  variable label context     stat_name   stat
#>    <chr>                <chr>    <chr> <chr>       <chr>      <dbl>
#>  1 Placebo              AGEGR1   65-80 categorical n         42    
#>  2 Placebo              AGEGR1   65-80 categorical N         86    
#>  3 Placebo              AGEGR1   65-80 categorical p          0.488
#>  4 Placebo              AGEGR1   <65   categorical n         14    
#>  5 Placebo              AGEGR1   <65   categorical N         86    
#>  6 Placebo              AGEGR1   <65   categorical p          0.163
#>  7 Placebo              AGEGR1   >80   categorical n         30    
#>  8 Placebo              AGEGR1   >80   categorical N         86    
#>  9 Placebo              AGEGR1   >80   categorical p          0.349
#> 10 Xanomeline High Dose AGEGR1   65-80 categorical n         55    
#> # ℹ 50 more rows