# Generating QC-Ready Result Data Frames (ARDs) from Tables

#### Davide Garolini

#### 2025-01-09

# Disclaimer

This vignette is a work in progress and subject to change.

## Creating an Example Table

In order to generate an ARD (Analysis Results Dataset), we first need to create a table from which all the necessary information will be retrieved. We will borrow a simple table from this vignette about clinical trials.

    library(rtables)
    ADSL <- ex_adsl # Example ADSL dataset

    # Very simple table
    lyt <- basic_table() %>%
      split_cols_by("ARM") %>%
      analyze(c("AGE", "SEX"))

    tbl <- build_table(lyt, ADSL)
    tbl
    #                      A: Drug X   B: Placebo   C: Combination
    # ————————————————————————————————————————————————————————————
    # AGE
    #   Mean                 33.77       35.43          35.43
    # SEX
    #   F                     79           77             66
    #   M                     51           55             60
    #   U                      3           2              4
    #   UNDIFFERENTIATED       1           0              2

## Converting the Table to a Result Data Frame (ARD)

The `as_result_df()` function is used to convert a table to a result data frame. The result data frame is a data frame that contains the result of the summary table and is ready to be used for quality control purposes. This may be customized according to different standards.

Let’s see how we can produce different result `data.frame`s. The following outputs can be returned by setting different parameters in the `as_results_df()` function, and these results can be transformed back into a table using the `df_to_tt()` function.

    as_result_df(tbl)
    #                    group1 group1_level avar_name         row_name
    # 1 <analysis_spl_tbl_name>   ma_AGE_SEX       AGE             Mean
    # 2 <analysis_spl_tbl_name>   ma_AGE_SEX       SEX                F
    # 3 <analysis_spl_tbl_name>   ma_AGE_SEX       SEX                M
    # 4 <analysis_spl_tbl_name>   ma_AGE_SEX       SEX                U
    # 5 <analysis_spl_tbl_name>   ma_AGE_SEX       SEX UNDIFFERENTIATED
    #         label_name row_num is_group_summary node_class A: Drug X B: Placebo
    # 1             Mean       2            FALSE    DataRow  33.76866   35.43284
    # 2                F       4            FALSE    DataRow        79         77
    # 3                M       5            FALSE    DataRow        51         55
    # 4                U       6            FALSE    DataRow         3          2
    # 5 UNDIFFERENTIATED       7            FALSE    DataRow         1          0
    #   C: Combination
    # 1       35.43182
    # 2             66
    # 3             60
    # 4              4
    # 5              2

    as_result_df(tbl, data_format = "strings")
    #                    group1 group1_level avar_name         row_name
    # 1 <analysis_spl_tbl_name>   ma_AGE_SEX       AGE             Mean
    # 2 <analysis_spl_tbl_name>   ma_AGE_SEX       SEX                F
    # 3 <analysis_spl_tbl_name>   ma_AGE_SEX       SEX                M
    # 4 <analysis_spl_tbl_name>   ma_AGE_SEX       SEX                U
    # 5 <analysis_spl_tbl_name>   ma_AGE_SEX       SEX UNDIFFERENTIATED
    #         label_name row_num is_group_summary node_class A: Drug X B: Placebo
    # 1             Mean       2            FALSE    DataRow     33.77      35.43
    # 2                F       4            FALSE    DataRow        79         77
    # 3                M       5            FALSE    DataRow        51         55
    # 4                U       6            FALSE    DataRow         3          2
    # 5 UNDIFFERENTIATED       7            FALSE    DataRow         1          0
    #   C: Combination
    # 1          35.43
    # 2             66
    # 3             60
    # 4              4
    # 5              2
    as_result_df(tbl, simplify = TRUE)
    #         label_name A: Drug X B: Placebo C: Combination
    # 1             Mean  33.76866   35.43284       35.43182
    # 2                F        79         77             66
    # 3                M        51         55             60
    # 4                U         3          2              4
    # 5 UNDIFFERENTIATED         1          0              2
    as_result_df(tbl, simplify = TRUE, keep_label_rows = TRUE)
    #         label_name A: Drug X B: Placebo C: Combination
    # 1              AGE        NA         NA             NA
    # 2             Mean  33.76866   35.43284       35.43182
    # 3              SEX        NA         NA             NA
    # 4                F        79         77             66
    # 5                M        51         55             60
    # 6                U         3          2              4
    # 7 UNDIFFERENTIATED         1          0              2
    as_result_df(tbl, simplify = TRUE, keep_label_rows = TRUE, expand_colnames = TRUE)
    #                label_name A: Drug X B: Placebo C: Combination
    # 1 <only_for_column_names> A: Drug X B: Placebo C: Combination
    # 2                     AGE        NA         NA             NA
    # 3                    Mean  33.76866   35.43284       35.43182
    # 4                     SEX        NA         NA             NA
    # 5                       F        79         77             66
    # 6                       M        51         55             60
    # 7                       U         3          2              4
    # 8        UNDIFFERENTIATED         1          0              2

Now let’s generate our final ARD output, which is ready to be used for quality control purposes.

    as_result_df(tbl, make_ard = TRUE)
    #                     group1 group1_level group2   group2_level variable
    # 1  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM      A: Drug X      AGE
    # 2  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM      A: Drug X      SEX
    # 3  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM      A: Drug X      SEX
    # 4  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM      A: Drug X      SEX
    # 5  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM      A: Drug X      SEX
    # 6  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM     B: Placebo      AGE
    # 7  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM     B: Placebo      SEX
    # 8  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM     B: Placebo      SEX
    # 9  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM     B: Placebo      SEX
    # 10 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM     B: Placebo      SEX
    # 11 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM C: Combination      AGE
    # 12 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM C: Combination      SEX
    # 13 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM C: Combination      SEX
    # 14 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM C: Combination      SEX
    # 15 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM C: Combination      SEX
    #      variable_level   variable_label stat_name     stat
    # 1              Mean             Mean      mean 33.76866
    # 2                 F                F         n 79.00000
    # 3                 M                M         n 51.00000
    # 4                 U                U         n  3.00000
    # 5  UNDIFFERENTIATED UNDIFFERENTIATED         n  1.00000
    # 6              Mean             Mean      mean 35.43284
    # 7                 F                F         n 77.00000
    # 8                 M                M         n 55.00000
    # 9                 U                U         n  2.00000
    # 10 UNDIFFERENTIATED UNDIFFERENTIATED         n  0.00000
    # 11             Mean             Mean      mean 35.43182
    # 12                F                F         n 66.00000
    # 13                M                M         n 60.00000
    # 14                U                U         n  4.00000
    # 15 UNDIFFERENTIATED UNDIFFERENTIATED         n  2.00000

## Customizing the Output

`as_result_df()` and ARDs depend on the content of the table, so it is possible to modify the table to customize the output. For example, we can add some user-defined statistics with custom names:

    # rcell and in_rows are the core of any analysis function
    rc <- rcell(c(1, 2), stat_names = c("Rand1", "Rand2"))
    print(obj_stat_names(rc)) # c("Rand1", "Rand2")
    # [1] "Rand1" "Rand2"

    rc_row <- in_rows(
      .list = list(a = c(NA, 1), b = c(1, NA)),
      .formats = c("xx - xx", "xx.x - xx.x"),
      .format_na_strs = list(c("asda", "lkjklj")),
      .stat_names = list(c("A", "B"), c("B", "C"))
    )

    # Only a getter for this object
    print(obj_stat_names(rc_row)) # list(a = c("A", "B"), b = c("B", "C"))
    # $a
    # [1] "A" "B"
    #
    # $b
    # [1] "B" "C"

    # if c("A", "B"), one for each row
    # if single list, duplicated
    rc_row <- in_rows(
      .list = list(a = c(NA, 1), b = c(1, NA)),
      .formats = c("xx - xx", "xx.x - xx.x"),
      .format_na_strs = list(c("asda", "lkjklj")),
      .stat_names = c("A", "B")
    )
    print(obj_stat_names(rc_row)) # c("A", "B") # one for each row
    # $a
    # [1] "A"
    #
    # $b
    # [1] "B"
    print(lapply(rc_row, obj_stat_names)) # identical to above + row names
    # $a
    # [1] "A"
    #
    # $b
    # [1] "B"

    rc_row <- in_rows(
      .list = list(a = c(NA, 1), b = c(1, NA)),
      .formats = c("xx - xx", "xx.x - xx.x"),
      .format_na_strs = list(c("asda", "lkjklj")),
      .stat_names = list(c("A", "B")) # It is duplicated, check it yourself!
    )

Let’s put it into practice:

    mean_sd_custom <- function(x) {
      mean <- mean(x, na.rm = FALSE)
      sd <- sd(x, na.rm = FALSE)

      rcell(c(mean, sd),
        label = "Mean (SD)", format = "xx.x (xx.x)" # ,
        # stat_names = c("Mean", "SD")
      )
    }
    counts_percentage_custom <- function(x) {
      cnts <- table(x)
      out <- lapply(cnts, function(x) {
        perc <- x / sum(cnts)
        rcell(c(x, perc), format = "xx. (xx.%)")
      })
      in_rows(
        .list = as.list(out), .labels = names(cnts),
        .stat_names = list(c("Count", "Percentage"))
      )
    }

    lyt <- basic_table(show_colcounts = TRUE, colcount_format = "N=xx") %>%
      split_cols_by("ARM", split_fun = keep_split_levels(c("A: Drug X", "B: Placebo"))) %>%
      analyze(vars = "AGE", afun = mean_sd_custom) %>%
      analyze(vars = "SEX", afun = counts_percentage_custom)

    tbl <- build_table(lyt, ex_adsl)

    as_result_df(tbl, make_ard = TRUE)
    #                     group1 group1_level group2 group2_level variable
    # 1  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      AGE
    # 2  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      AGE
    # 3  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      SEX
    # 4  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      SEX
    # 5  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      SEX
    # 6  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      SEX
    # 7  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      SEX
    # 8  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      SEX
    # 9  <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      SEX
    # 10 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM    A: Drug X      SEX
    # 11 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      AGE
    # 12 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      AGE
    # 13 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      SEX
    # 14 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      SEX
    # 15 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      SEX
    # 16 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      SEX
    # 17 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      SEX
    # 18 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      SEX
    # 19 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      SEX
    # 20 <analysis_spl_tbl_name>   ma_AGE_SEX    ARM   B: Placebo      SEX
    #      variable_level   variable_label  stat_name         stat
    # 1         Mean (SD)        Mean (SD)       <NA> 33.768656716
    # 2         Mean (SD)        Mean (SD)       <NA>  6.553325712
    # 3                 F                F      Count 79.000000000
    # 4                 F                F Percentage  0.589552239
    # 5                 M                M      Count 51.000000000
    # 6                 M                M Percentage  0.380597015
    # 7                 U                U      Count  3.000000000
    # 8                 U                U Percentage  0.022388060
    # 9  UNDIFFERENTIATED UNDIFFERENTIATED      Count  1.000000000
    # 10 UNDIFFERENTIATED UNDIFFERENTIATED Percentage  0.007462687
    # 11        Mean (SD)        Mean (SD)       <NA> 35.432835821
    # 12        Mean (SD)        Mean (SD)       <NA>  7.895413879
    # 13                F                F      Count 77.000000000
    # 14                F                F Percentage  0.574626866
    # 15                M                M      Count 55.000000000
    # 16                M                M Percentage  0.410447761
    # 17                U                U      Count  2.000000000
    # 18                U                U Percentage  0.014925373
    # 19 UNDIFFERENTIATED UNDIFFERENTIATED      Count  0.000000000
    # 20 UNDIFFERENTIATED UNDIFFERENTIATED Percentage  0.000000000

# More Complex Outputs

Let’s add hierarchical row and column splits:

    lyt <- basic_table() %>%
      split_rows_by("STRATA2") %>%
      summarize_row_groups() %>%
      split_cols_by("ARM") %>%
      split_cols_by("STRATA1") %>%
      analyze(c("AGE", "SEX"))

    tbl <- build_table(lyt, ex_adsl)

    as_result_df(tbl, make_ard = TRUE)
    #      group1 group1_level group2   group2_level  group3 group3_level variable
    # 1   STRATA2           S1    ARM      A: Drug X STRATA1            A  STRATA2
    # 2   STRATA2           S1    ARM      A: Drug X STRATA1            A  STRATA2
    # 3   STRATA2           S1    ARM      A: Drug X STRATA1            A      AGE
    # 4   STRATA2           S1    ARM      A: Drug X STRATA1            A      SEX
    # 5   STRATA2           S1    ARM      A: Drug X STRATA1            A      SEX
    # 6   STRATA2           S1    ARM      A: Drug X STRATA1            A      SEX
    # 7   STRATA2           S1    ARM      A: Drug X STRATA1            A      SEX
    # 8   STRATA2           S2    ARM      A: Drug X STRATA1            A  STRATA2
    # 9   STRATA2           S2    ARM      A: Drug X STRATA1            A  STRATA2
    # 10  STRATA2           S2    ARM      A: Drug X STRATA1            A      AGE
    # 11  STRATA2           S2    ARM      A: Drug X STRATA1            A      SEX
    # 12  STRATA2           S2    ARM      A: Drug X STRATA1            A      SEX
    # 13  STRATA2           S2    ARM      A: Drug X STRATA1            A      SEX
    # 14  STRATA2           S2    ARM      A: Drug X STRATA1            A      SEX
    # 15  STRATA2           S1    ARM      A: Drug X STRATA1            B  STRATA2
    # 16  STRATA2           S1    ARM      A: Drug X STRATA1            B  STRATA2
    # 17  STRATA2           S1    ARM      A: Drug X STRATA1            B      AGE
    # 18  STRATA2           S1    ARM      A: Drug X STRATA1            B      SEX
    # 19  STRATA2           S1    ARM      A: Drug X STRATA1            B      SEX
    # 20  STRATA2           S1    ARM      A: Drug X STRATA1            B      SEX
    # 21  STRATA2           S1    ARM      A: Drug X STRATA1            B      SEX
    # 22  STRATA2           S2    ARM      A: Drug X STRATA1            B  STRATA2
    # 23  STRATA2           S2    ARM      A: Drug X STRATA1            B  STRATA2
    # 24  STRATA2           S2    ARM      A: Drug X STRATA1            B      AGE
    # 25  STRATA2           S2    ARM      A: Drug X STRATA1            B      SEX
    # 26  STRATA2           S2    ARM      A: Drug X STRATA1            B      SEX
    # 27  STRATA2           S2    ARM      A: Drug X STRATA1            B      SEX
    # 28  STRATA2           S2    ARM      A: Drug X STRATA1            B      SEX
    # 29  STRATA2           S1    ARM      A: Drug X STRATA1            C  STRATA2
    # 30  STRATA2           S1    ARM      A: Drug X STRATA1            C  STRATA2
    # 31  STRATA2           S1    ARM      A: Drug X STRATA1            C      AGE
    # 32  STRATA2           S1    ARM      A: Drug X STRATA1            C      SEX
    # 33  STRATA2           S1    ARM      A: Drug X STRATA1            C      SEX
    # 34  STRATA2           S1    ARM      A: Drug X STRATA1            C      SEX
    # 35  STRATA2           S1    ARM      A: Drug X STRATA1            C      SEX
    # 36  STRATA2           S2    ARM      A: Drug X STRATA1            C  STRATA2
    # 37  STRATA2           S2    ARM      A: Drug X STRATA1            C  STRATA2
    # 38  STRATA2           S2    ARM      A: Drug X STRATA1            C      AGE
    # 39  STRATA2           S2    ARM      A: Drug X STRATA1            C      SEX
    # 40  STRATA2           S2    ARM      A: Drug X STRATA1            C      SEX
    # 41  STRATA2           S2    ARM      A: Drug X STRATA1            C      SEX
    # 42  STRATA2           S2    ARM      A: Drug X STRATA1            C      SEX
    # 43  STRATA2           S1    ARM     B: Placebo STRATA1            A  STRATA2
    # 44  STRATA2           S1    ARM     B: Placebo STRATA1            A  STRATA2
    # 45  STRATA2           S1    ARM     B: Placebo STRATA1            A      AGE
    # 46  STRATA2           S1    ARM     B: Placebo STRATA1            A      SEX
    # 47  STRATA2           S1    ARM     B: Placebo STRATA1            A      SEX
    # 48  STRATA2           S1    ARM     B: Placebo STRATA1            A      SEX
    # 49  STRATA2           S1    ARM     B: Placebo STRATA1            A      SEX
    # 50  STRATA2           S2    ARM     B: Placebo STRATA1            A  STRATA2
    # 51  STRATA2           S2    ARM     B: Placebo STRATA1            A  STRATA2
    # 52  STRATA2           S2    ARM     B: Placebo STRATA1            A      AGE
    # 53  STRATA2           S2    ARM     B: Placebo STRATA1            A      SEX
    # 54  STRATA2           S2    ARM     B: Placebo STRATA1            A      SEX
    # 55  STRATA2           S2    ARM     B: Placebo STRATA1            A      SEX
    # 56  STRATA2           S2    ARM     B: Placebo STRATA1            A      SEX
    # 57  STRATA2           S1    ARM     B: Placebo STRATA1            B  STRATA2
    # 58  STRATA2           S1    ARM     B: Placebo STRATA1            B  STRATA2
    # 59  STRATA2           S1    ARM     B: Placebo STRATA1            B      AGE
    # 60  STRATA2           S1    ARM     B: Placebo STRATA1            B      SEX
    # 61  STRATA2           S1    ARM     B: Placebo STRATA1            B      SEX
    # 62  STRATA2           S1    ARM     B: Placebo STRATA1            B      SEX
    # 63  STRATA2           S1    ARM     B: Placebo STRATA1            B      SEX
    # 64  STRATA2           S2    ARM     B: Placebo STRATA1            B  STRATA2
    # 65  STRATA2           S2    ARM     B: Placebo STRATA1            B  STRATA2
    # 66  STRATA2           S2    ARM     B: Placebo STRATA1            B      AGE
    # 67  STRATA2           S2    ARM     B: Placebo STRATA1            B      SEX
    # 68  STRATA2           S2    ARM     B: Placebo STRATA1            B      SEX
    # 69  STRATA2           S2    ARM     B: Placebo STRATA1            B      SEX
    # 70  STRATA2           S2    ARM     B: Placebo STRATA1            B      SEX
    # 71  STRATA2           S1    ARM     B: Placebo STRATA1            C  STRATA2
    # 72  STRATA2           S1    ARM     B: Placebo STRATA1            C  STRATA2
    # 73  STRATA2           S1    ARM     B: Placebo STRATA1            C      AGE
    # 74  STRATA2           S1    ARM     B: Placebo STRATA1            C      SEX
    # 75  STRATA2           S1    ARM     B: Placebo STRATA1            C      SEX
    # 76  STRATA2           S1    ARM     B: Placebo STRATA1            C      SEX
    # 77  STRATA2           S1    ARM     B: Placebo STRATA1            C      SEX
    # 78  STRATA2           S2    ARM     B: Placebo STRATA1            C  STRATA2
    # 79  STRATA2           S2    ARM     B: Placebo STRATA1            C  STRATA2
    # 80  STRATA2           S2    ARM     B: Placebo STRATA1            C      AGE
    # 81  STRATA2           S2    ARM     B: Placebo STRATA1            C      SEX
    # 82  STRATA2           S2    ARM     B: Placebo STRATA1            C      SEX
    # 83  STRATA2           S2    ARM     B: Placebo STRATA1            C      SEX
    # 84  STRATA2           S2    ARM     B: Placebo STRATA1            C      SEX
    # 85  STRATA2           S1    ARM C: Combination STRATA1            A  STRATA2
    # 86  STRATA2           S1    ARM C: Combination STRATA1            A  STRATA2
    # 87  STRATA2           S1    ARM C: Combination STRATA1            A      AGE
    # 88  STRATA2           S1    ARM C: Combination STRATA1            A      SEX
    # 89  STRATA2           S1    ARM C: Combination STRATA1            A      SEX
    # 90  STRATA2           S1    ARM C: Combination STRATA1            A      SEX
    # 91  STRATA2           S1    ARM C: Combination STRATA1            A      SEX
    # 92  STRATA2           S2    ARM C: Combination STRATA1            A  STRATA2
    # 93  STRATA2           S2    ARM C: Combination STRATA1            A  STRATA2
    # 94  STRATA2           S2    ARM C: Combination STRATA1            A      AGE
    # 95  STRATA2           S2    ARM C: Combination STRATA1            A      SEX
    # 96  STRATA2           S2    ARM C: Combination STRATA1            A      SEX
    # 97  STRATA2           S2    ARM C: Combination STRATA1            A      SEX
    # 98  STRATA2           S2    ARM C: Combination STRATA1            A      SEX
    # 99  STRATA2           S1    ARM C: Combination STRATA1            B  STRATA2
    # 100 STRATA2           S1    ARM C: Combination STRATA1            B  STRATA2
    # 101 STRATA2           S1    ARM C: Combination STRATA1            B      AGE
    # 102 STRATA2           S1    ARM C: Combination STRATA1            B      SEX
    # 103 STRATA2           S1    ARM C: Combination STRATA1            B      SEX
    # 104 STRATA2           S1    ARM C: Combination STRATA1            B      SEX
    # 105 STRATA2           S1    ARM C: Combination STRATA1            B      SEX
    # 106 STRATA2           S2    ARM C: Combination STRATA1            B  STRATA2
    # 107 STRATA2           S2    ARM C: Combination STRATA1            B  STRATA2
    # 108 STRATA2           S2    ARM C: Combination STRATA1            B      AGE
    # 109 STRATA2           S2    ARM C: Combination STRATA1            B      SEX
    # 110 STRATA2           S2    ARM C: Combination STRATA1            B      SEX
    # 111 STRATA2           S2    ARM C: Combination STRATA1            B      SEX
    # 112 STRATA2           S2    ARM C: Combination STRATA1            B      SEX
    # 113 STRATA2           S1    ARM C: Combination STRATA1            C  STRATA2
    # 114 STRATA2           S1    ARM C: Combination STRATA1            C  STRATA2
    # 115 STRATA2           S1    ARM C: Combination STRATA1            C      AGE
    # 116 STRATA2           S1    ARM C: Combination STRATA1            C      SEX
    # 117 STRATA2           S1    ARM C: Combination STRATA1            C      SEX
    # 118 STRATA2           S1    ARM C: Combination STRATA1            C      SEX
    # 119 STRATA2           S1    ARM C: Combination STRATA1            C      SEX
    # 120 STRATA2           S2    ARM C: Combination STRATA1            C  STRATA2
    # 121 STRATA2           S2    ARM C: Combination STRATA1            C  STRATA2
    # 122 STRATA2           S2    ARM C: Combination STRATA1            C      AGE
    # 123 STRATA2           S2    ARM C: Combination STRATA1            C      SEX
    # 124 STRATA2           S2    ARM C: Combination STRATA1            C      SEX
    # 125 STRATA2           S2    ARM C: Combination STRATA1            C      SEX
    # 126 STRATA2           S2    ARM C: Combination STRATA1            C      SEX
    #       variable_level   variable_label stat_name       stat
    # 1                 S1               S1         n 18.0000000
    # 2                 S1               S1         p  0.4736842
    # 3               Mean             Mean      mean 31.6111111
    # 4                  F                F         n 12.0000000
    # 5                  M                M         n  5.0000000
    # 6                  U                U         n  1.0000000
    # 7   UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 8                 S2               S2         n 20.0000000
    # 9                 S2               S2         p  0.5263158
    # 10              Mean             Mean      mean 34.4000000
    # 11                 F                F         n  9.0000000
    # 12                 M                M         n 11.0000000
    # 13                 U                U         n  0.0000000
    # 14  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 15                S1               S1         n 28.0000000
    # 16                S1               S1         p  0.5957447
    # 17              Mean             Mean      mean 34.5714286
    # 18                 F                F         n 14.0000000
    # 19                 M                M         n 13.0000000
    # 20                 U                U         n  1.0000000
    # 21  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 22                S2               S2         n 19.0000000
    # 23                S2               S2         p  0.4042553
    # 24              Mean             Mean      mean 32.7894737
    # 25                 F                F         n 11.0000000
    # 26                 M                M         n  8.0000000
    # 27                 U                U         n  0.0000000
    # 28  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 29                S1               S1         n 27.0000000
    # 30                S1               S1         p  0.5510204
    # 31              Mean             Mean      mean 35.2592593
    # 32                 F                F         n 17.0000000
    # 33                 M                M         n  8.0000000
    # 34                 U                U         n  1.0000000
    # 35  UNDIFFERENTIATED UNDIFFERENTIATED         n  1.0000000
    # 36                S2               S2         n 22.0000000
    # 37                S2               S2         p  0.4489796
    # 38              Mean             Mean      mean 32.9545455
    # 39                 F                F         n 16.0000000
    # 40                 M                M         n  6.0000000
    # 41                 U                U         n  0.0000000
    # 42  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 43                S1               S1         n 22.0000000
    # 44                S1               S1         p  0.5000000
    # 45              Mean             Mean      mean 36.6818182
    # 46                 F                F         n 11.0000000
    # 47                 M                M         n 10.0000000
    # 48                 U                U         n  1.0000000
    # 49  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 50                S2               S2         n 22.0000000
    # 51                S2               S2         p  0.5000000
    # 52              Mean             Mean      mean 33.5454545
    # 53                 F                F         n 13.0000000
    # 54                 M                M         n  9.0000000
    # 55                 U                U         n  0.0000000
    # 56  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 57                S1               S1         n 19.0000000
    # 58                S1               S1         p  0.4222222
    # 59              Mean             Mean      mean 37.6842105
    # 60                 F                F         n 12.0000000
    # 61                 M                M         n  7.0000000
    # 62                 U                U         n  0.0000000
    # 63  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 64                S2               S2         n 26.0000000
    # 65                S2               S2         p  0.5777778
    # 66              Mean             Mean      mean 34.7692308
    # 67                 F                F         n 15.0000000
    # 68                 M                M         n 10.0000000
    # 69                 U                U         n  1.0000000
    # 70  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 71                S1               S1         n 26.0000000
    # 72                S1               S1         p  0.5777778
    # 73              Mean             Mean      mean 35.3846154
    # 74                 F                F         n 13.0000000
    # 75                 M                M         n 13.0000000
    # 76                 U                U         n  0.0000000
    # 77  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 78                S2               S2         n 19.0000000
    # 79                S2               S2         p  0.4222222
    # 80              Mean             Mean      mean 34.8947368
    # 81                 F                F         n 13.0000000
    # 82                 M                M         n  6.0000000
    # 83                 U                U         n  0.0000000
    # 84  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 85                S1               S1         n 14.0000000
    # 86                S1               S1         p  0.3500000
    # 87              Mean             Mean      mean 34.0000000
    # 88                 F                F         n  7.0000000
    # 89                 M                M         n  6.0000000
    # 90                 U                U         n  1.0000000
    # 91  UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 92                S2               S2         n 26.0000000
    # 93                S2               S2         p  0.6500000
    # 94              Mean             Mean      mean 34.3461538
    # 95                 F                F         n 11.0000000
    # 96                 M                M         n 14.0000000
    # 97                 U                U         n  0.0000000
    # 98  UNDIFFERENTIATED UNDIFFERENTIATED         n  1.0000000
    # 99                S1               S1         n 18.0000000
    # 100               S1               S1         p  0.4186047
    # 101             Mean             Mean      mean 35.8333333
    # 102                F                F         n  9.0000000
    # 103                M                M         n  9.0000000
    # 104                U                U         n  0.0000000
    # 105 UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 106               S2               S2         n 25.0000000
    # 107               S2               S2         p  0.5813953
    # 108             Mean             Mean      mean 36.6800000
    # 109                F                F         n 12.0000000
    # 110                M                M         n 12.0000000
    # 111                U                U         n  1.0000000
    # 112 UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000
    # 113               S1               S1         n 24.0000000
    # 114               S1               S1         p  0.4897959
    # 115             Mean             Mean      mean 36.5833333
    # 116                F                F         n 14.0000000
    # 117                M                M         n  8.0000000
    # 118                U                U         n  1.0000000
    # 119 UNDIFFERENTIATED UNDIFFERENTIATED         n  1.0000000
    # 120               S2               S2         n 25.0000000
    # 121               S2               S2         p  0.5102041
    # 122             Mean             Mean      mean 34.7200000
    # 123                F                F         n 13.0000000
    # 124                M                M         n 11.0000000
    # 125                U                U         n  1.0000000
    # 126 UNDIFFERENTIATED UNDIFFERENTIATED         n  0.0000000