sort_ard_hierarchical {cards}R Documentation

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 = c("descending", "alphanumeric"))

Arguments

x

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

sort

(string)
type of sorting to perform. Value must be one of:

  • "alphanumeric" - within each hierarchical section of the ARD, groups are ordered alphanumerically (i.e. A to Z) by variable_level text.

  • "descending" - within each variable group of the ARD, count sums are calculated for each group and groups are sorted in descending order by sum. If sort = "descending", the n statistic is used to calculate variable group sums if included in statistic for all variables, otherwise p is used. If neither n nor p are present in x for all variables, an error will occur.

Defaults to "descending".

Value

an ARD data frame of class 'card'

Note

If overall data is present in x (i.e. the ARD was created with ard_stack_hierarchical(overall=TRUE)), the overall data will be sorted last within each variable group (i.e. after any other rows with the same combination of variable levels).

See Also

filter_ard_hierarchical()

Examples


ard_stack_hierarchical(
  ADAE,
  variables = c(AESOC, AEDECOD),
  by = TRTA,
  denominator = ADSL,
  id = USUBJID
) |>
  sort_ard_hierarchical("alphanumeric")

ard_stack_hierarchical_count(
  ADAE,
  variables = c(AESOC, AEDECOD),
  by = TRTA,
  denominator = ADSL
) |>
  sort_ard_hierarchical("descending")


[Package cards version 0.6.1 Index]