Learn R Programming

cards (version 0.7.0)

sort_ard_hierarchical: Sort Stacked Hierarchical ARDs

Description

[Experimental]

This function is used to sort stacked hierarchical ARDs.

For the purposes of this function, we define a "variable group" as a combination of ARD rows grouped by the combination of all their variable levels, but excluding any by variables.

Usage

sort_ard_hierarchical(x, sort = everything() ~ "descending")

Value

an ARD data frame of class 'card'

Arguments

x

(card)
a stacked hierarchical ARD of class 'card' created using ard_stack_hierarchical() or ard_stack_hierarchical_count().

sort

(formula-list-selector, string)
a named list, a list of formulas, a single formula where the list element is a named list of functions (or the RHS of a formula), or a single string specifying the types of sorting to perform at each hierarchy variable level. If the sort method for any variable is not specified then the method will default to "descending". If a single unnamed string is supplied it is applied to all variables. For each variable, the value specified must be one of:

  • "alphanumeric" - at the specified hierarchy level of the ARD, groups are ordered alphanumerically (i.e. A to Z) by variable_level text.

  • "descending" - within each variable group of the ARD at the specified hierarchy level, count sums are calculated for each group and groups are sorted in descending order by sum. When sort is "descending" for a given variable and n is included in statistic for the variable then n is used to calculate variable group sums, otherwise p is used. If neither n nor p are present in x for the variable, an error will occur.

Defaults to everything() ~ "descending".

See Also

filter_ard_hierarchical()