ARD functions for relocating columns and rows to the standard order.

  • tidy_ard_column_order() relocates columns of the ARD to the standard order.

  • tidy_ard_row_order() orders rows of ARD according to groups and strata (group 1, then group2, etc), while retaining the column order of the input ARD.

tidy_ard_column_order(x, group_order = c("ascending", "descending"))

tidy_ard_row_order(x)

Arguments

x

(data.frame)
an ARD data frame of class 'card'

group_order

(string)
specifies the ordering of the grouping variables. Must be one of c("ascending", "descending"). Default is "ascending", where grouping variables begin with "group1" variables, followed by "group2" variables, etc.

Value

an ARD data frame of class 'card'

Examples

# order columns
ard <-
  dplyr::bind_rows(
    ard_summary(mtcars, variables = "mpg"),
    ard_summary(mtcars, variables = "mpg", by = "cyl")
  )

tidy_ard_column_order(ard) |>
  tidy_ard_row_order()
#> # An ARD data frame: 32 × 10
#>    group1 group1_level variable context stat_name stat_label   stat fmt_fun
#>    <chr>  <list>       <chr>    <chr>   <chr>     <chr>      <list>  <list>
#>  1 NA     <NULL>       mpg      summary N         N           32          0
#>  2 NA     <NULL>       mpg      summary mean      Mean        20.1        1
#>  3 NA     <NULL>       mpg      summary sd        SD           6.03       1
#>  4 NA     <NULL>       mpg      summary median    Median      19.2        1
#>  5 NA     <NULL>       mpg      summary p25       Q1          15.4        1
#>  6 NA     <NULL>       mpg      summary p75       Q3          22.8        1
#>  7 NA     <NULL>       mpg      summary min       Min         10.4        1
#>  8 NA     <NULL>       mpg      summary max       Max         33.9        1
#>  9 cyl    4            mpg      summary N         N           11          0
#> 10 cyl    4            mpg      summary mean      Mean        26.7        1
#> # ℹ 22 more rows
#> # ℹ 2 more variables: warning <list>, error <list>