Skip to contents

Stack multiple ARD calls sharing common input data and by variables. Optionally incorporate additional information on represented variables (i.e. big N's, missingness, attributes) and/or tidy for use in displays with shuffle_ard().

Usage

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

Arguments

data

(data.frame)
a data frame

by

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

...

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

.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.

.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,
  by = "ARM",
  ard_categorical(variables = "AGEGR1"),
  ard_continuous(variables = "AGE")
)
#> {cards} data frame: 54 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
#>  44 more rows
#>  Use `print(n = ...)` to see more rows
#>  4 more variables: context, fmt_fn, warning, error

ard_stack(
  data = ADSL,
  by = "ARM",
  ard_categorical(variables = "AGEGR1"),
  ard_continuous(variables = "AGE"),
  .shuffle = TRUE
)
#> # A tibble: 54 × 6
#>    ARM                  variable label context     stat_name   stat
#>    <chr>                <fct>    <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    
#> # ℹ 44 more rows