Typical use is tabulating changes from baseline measurement of an Analysis Variable.

tbl_baseline_chg(
  data,
  baseline_level,
  denominator,
  by = NULL,
  digits = NULL,
  id = "USUBJID",
  visit = "AVISIT",
  visit_number = "AVISITN",
  analysis_variable = "AVAL",
  change_variable = "CHG"
)

# S3 method for class 'tbl_baseline_chg'
add_overall(
  x,
  last = FALSE,
  col_label = "All Participants  \n(N = {style_roche_number(n)})",
  ...
)

Arguments

data

(data.frame)
A data frame.

baseline_level

(string)
String identifying baseline level in the visit variable.

denominator

(data.frame)
Data set used to compute the header counts (typically ADSL).

by

(tidy-select)
A single column from data. Summary statistics will be stratified by this variable. Default is NULL.

digits

(formula-list-selector)
Specifies how summary statistics are rounded. Values may be either integer(s) or function(s). If not specified, default formatting is assigned via assign_summary_digits(). See below for details.

id

(tidy-select)
String identifying the unique subjects. Default is 'USUBJID'.

visit

(tidy-select)
String for the visit variable. Default is 'AVISIT'. If there are more than one entry for each visit and subject, only the first row is kept.

visit_number

(tidy-select)
String identifying the visit or analysis sequence number. Default is 'AVISITN'.

analysis_variable

(tidy-select)
String identifying the analysis values. Default is 'AVAL'.

change_variable

(tidy-select)
String identifying the change from baseline values. Default is 'CHG'.

x

(tbl_summary, tbl_svysummary, tbl_continuous, tbl_custom_summary)
A stratified 'gtsummary' table

last

(scalar logical)
Logical indicator to display overall column last in table. Default is FALSE, which will display overall column first.

col_label

(string)
String indicating the column label. Default is "**Overall** \nN = {style_number(N)}"

...

These dots are for future extensions and must be empty.

Value

A gtsummary table.

Examples

theme_gtsummary_roche()
#> Setting theme "Roche"

df <- cards::ADLB |>
  dplyr::mutate(AVISIT = trimws(AVISIT)) |>
  dplyr::filter(
    AVISIT != "End of Treatment",
    PARAMCD %in% c("SODIUM", "K")
  )

tbl_baseline_chg(
  data = df |> dplyr::filter(PARAMCD == "SODIUM"),
  baseline_level = "Baseline",
  by = "TRTA",
  denominator = cards::ADSL
)
#>  Converting column "TRTA" to a factor.
Visit
Placebo
(N = 86)
Xanomeline High Dose
(N = 84)
Xanomeline Low Dose
(N = 84)
Value at Visit Change from Baseline Value at Visit Change from Baseline Value at Visit Change from Baseline
Baseline





    n 7
7
6
    Mean (SD) 141.1 (1.5)
139.1 (2.2)
139.5 (4.2)
    Median 141.0
139.0
138.5
    Min - Max 140 - 144
136 - 142
134 - 145
Week 2





    n 7 7 6 6 6 6
    Mean (SD) 140.6 (1.6) -0.6 (1.9) 138.8 (3.3) 0.2 (3.5) 139.5 (2.3) 0.0 (3.7)
    Median 141.0 -1.0 140.5 0.5 139.5 -0.5
    Min - Max 138 - 142 -3 - 2 133 - 141 -5 - 5 136 - 142 -5 - 5
Week 4





    n 7 7 6 6 5 5
    Mean (SD) 139.3 (2.8) -1.9 (2.5) 139.8 (3.5) 1.2 (2.0) 139.4 (1.3) -0.6 (3.5)
    Median 140.0 -1.0 138.5 0.0 140.0 0.0
    Min - Max 134 - 142 -7 - 0 138 - 147 0 - 5 138 - 141 -5 - 4
Week 6





    n 5 5 6 6 4 4
    Mean (SD) 140.0 (1.9) -0.4 (1.7) 139.7 (2.0) 1.0 (2.3) 140.5 (2.6) 1.8 (5.4)
    Median 140.0 0.0 139.0 0.5 140.0 2.5
    Min - Max 138 - 143 -2 - 2 138 - 143 -1 - 5 138 - 144 -5 - 7
Week 8





    n 5 5 4 4 3 3
    Mean (SD) 140.6 (1.5) 0.2 (1.6) 139.0 (2.2) -0.5 (2.4) 139.0 (2.6) 0.0 (3.5)
    Median 141.0 1.0 139.5 -0.5 140.0 2.0
    Min - Max 139 - 142 -2 - 2 136 - 141 -3 - 2 136 - 141 -4 - 2
Week 12





    n 5 5 4 4 2 2
    Mean (SD) 141.0 (1.6) 0.6 (1.1) 140.8 (3.0) 1.3 (1.3) 139.0 (0.0) 0.0 (7.1)
    Median 141.0 1.0 140.0 1.0 139.0 0.0
    Min - Max 139 - 143 -1 - 2 138 - 145 0 - 3 139 - 139 -5 - 5
Week 16





    n 5 5 4 4 2 2
    Mean (SD) 140.8 (1.1) 0.4 (0.9) 142.0 (3.6) 2.5 (1.9) 139.5 (0.7) 0.5 (6.4)
    Median 141.0 1.0 141.0 2.0 139.5 0.5
    Min - Max 139 - 142 -1 - 1 139 - 147 1 - 5 139 - 140 -4 - 5
Week 20





    n 5 5 4 4 2 2
    Mean (SD) 141.6 (1.7) 1.2 (1.9) 138.8 (3.6) -0.8 (2.2) 137.5 (0.7) -1.5 (6.4)
    Median 142.0 2.0 137.5 -1.0 137.5 -1.5
    Min - Max 139 - 143 -2 - 3 136 - 144 -3 - 2 137 - 138 -6 - 3
Week 24





    n 5 5 4 4 2 2
    Mean (SD) 140.4 (1.1) 0.0 (1.2) 139.3 (3.6) -0.3 (2.6) 138.0 (2.8) -1.0 (4.2)
    Median 140.0 0.0 140.5 0.5 138.0 -1.0
    Min - Max 139 - 142 -2 - 1 134 - 142 -4 - 2 136 - 140 -4 - 2
Week 26





    n 5 5 4 4 2 2
    Mean (SD) 140.6 (2.5) 0.2 (2.8) 138.8 (4.6) -0.8 (2.9) 142.5 (2.1) 3.5 (4.9)
    Median 140.0 -1.0 138.0 -1.0 142.5 3.5
    Min - Max 139 - 145 -2 - 5 134 - 145 -4 - 3 141 - 144 0 - 7
tbl_baseline_chg( data = df |> dplyr::filter(PARAMCD == "K"), baseline_level = "Baseline", by = "TRTA", denominator = cards::ADSL ) |> add_overall(last = TRUE, col_label = "All Participants") #> Converting column "TRTA" to a factor.
Visit
Placebo
(N = 86)
Xanomeline High Dose
(N = 84)
Xanomeline Low Dose
(N = 84)
All Participants
Value at Visit Change from Baseline Value at Visit Change from Baseline Value at Visit Change from Baseline Value at Visit Change from Baseline
Baseline







    n 7
7
6
20
    Mean (SD) 4.34 (0.40)
4.30 (0.18)
4.23 (0.37)
4.30 (0.31)
    Median 4.30
4.40
4.20
4.30
    Min - Max 3.7 - 4.9
4.0 - 4.5
3.8 - 4.7
3.7 - 4.9
Week 2







    n 7 7 6 6 6 6 19 19
    Mean (SD) 4.47 (0.42) 0.13 (0.46) 4.35 (0.27) 0.07 (0.12) 4.57 (0.38) 0.33 (0.40) 4.46 (0.36) 0.17 (0.36)
    Median 4.50 -0.10 4.40 0.05 4.60 0.25 4.50 0.10
    Min - Max 3.9 - 5.1 -0.4 - 1.0 3.9 - 4.6 -0.1 - 0.2 4.1 - 5.1 -0.2 - 0.8 3.9 - 5.1 -0.4 - 1.0
Week 4







    n 7 7 6 6 5 5 18 18
    Mean (SD) 4.44 (0.38) 0.10 (0.37) 4.32 (0.46) -0.02 (0.32) 4.46 (0.39) 0.16 (0.26) 4.41 (0.39) 0.08 (0.32)
    Median 4.60 0.00 4.45 0.05 4.70 0.20 4.55 0.05
    Min - Max 3.9 - 4.8 -0.4 - 0.7 3.4 - 4.6 -0.6 - 0.3 3.9 - 4.8 -0.2 - 0.4 3.4 - 4.8 -0.6 - 0.7
Week 6







    n 5 5 6 6 4 4 15 15
    Mean (SD) 4.50 (0.35) 0.26 (0.26) 4.20 (0.23) -0.13 (0.12) 4.53 (0.59) 0.18 (0.59) 4.39 (0.39) 0.08 (0.36)
    Median 4.60 0.10 4.25 -0.15 4.45 0.05 4.30 0.00
    Min - Max 4.0 - 4.8 0.1 - 0.7 3.8 - 4.4 -0.3 - 0.0 3.9 - 5.3 -0.4 - 1.0 3.8 - 5.3 -0.4 - 1.0
Week 8







    n 5 5 4 4 3 3 12 12
    Mean (SD) 4.18 (0.23) -0.06 (0.33) 4.18 (0.56) -0.13 (0.41) 4.73 (0.25) 0.50 (0.17) 4.32 (0.42) 0.06 (0.40)
    Median 4.10 0.00 4.20 -0.20 4.70 0.40 4.35 0.10
    Min - Max 3.9 - 4.5 -0.4 - 0.3 3.5 - 4.8 -0.5 - 0.4 4.5 - 5.0 0.4 - 0.7 3.5 - 5.0 -0.5 - 0.7
Week 12







    n 5 5 4 4 2 2 11 11
    Mean (SD) 4.06 (0.31) -0.18 (0.50) 4.13 (0.22) -0.18 (0.24) 4.10 (0.14) -0.10 (0.42) 4.09 (0.24) -0.16 (0.37)
    Median 4.20 0.10 4.10 -0.10 4.10 -0.10 4.20 0.00
    Min - Max 3.6 - 4.4 -0.9 - 0.2 3.9 - 4.4 -0.5 - 0.0 4.0 - 4.2 -0.4 - 0.2 3.6 - 4.4 -0.9 - 0.2
Week 16







    n 5 5 4 4 2 2 11 11
    Mean (SD) 4.24 (0.47) 0.00 (0.47) 4.35 (0.51) 0.05 (0.35) 4.35 (0.49) 0.15 (0.07) 4.30 (0.44) 0.05 (0.36)
    Median 4.10 -0.20 4.45 0.05 4.35 0.15 4.20 0.00
    Min - Max 3.7 - 4.9 -0.4 - 0.8 3.7 - 4.8 -0.3 - 0.4 4.0 - 4.7 0.1 - 0.2 3.7 - 4.9 -0.4 - 0.8
Week 20







    n 5 5 4 4 2 2 11 11
    Mean (SD) 4.26 (0.39) 0.02 (0.50) 4.15 (0.26) -0.15 (0.26) 4.10 (0.14) -0.10 (0.42) 4.19 (0.30) -0.06 (0.38)
    Median 4.20 -0.20 4.10 -0.10 4.10 -0.10 4.20 -0.20
    Min - Max 3.9 - 4.9 -0.5 - 0.8 3.9 - 4.5 -0.5 - 0.1 4.0 - 4.2 -0.4 - 0.2 3.9 - 4.9 -0.5 - 0.8
Week 24







    n 5 5 4 4 2 2 11 11
    Mean (SD) 4.26 (0.32) 0.02 (0.29) 4.20 (0.41) -0.10 (0.32) 4.00 (0.14) -0.20 (0.42) 4.19 (0.32) -0.06 (0.30)
    Median 4.30 0.10 4.20 -0.05 4.00 -0.20 4.10 0.10
    Min - Max 3.8 - 4.6 -0.4 - 0.4 3.8 - 4.6 -0.5 - 0.2 3.9 - 4.1 -0.5 - 0.1 3.8 - 4.6 -0.5 - 0.4
Week 26







    n 5 5 4 4 2 2 11 11
    Mean (SD) 4.18 (0.37) -0.06 (0.36) 4.28 (0.46) -0.03 (0.31) 4.50 (0.71) 0.30 (0.14) 4.27 (0.43) 0.02 (0.32)
    Median 4.20 0.00 4.30 -0.10 4.50 0.30 4.20 0.00
    Min - Max 3.6 - 4.5 -0.6 - 0.4 3.7 - 4.8 -0.3 - 0.4 4.0 - 5.0 0.2 - 0.4 3.6 - 5.0 -0.6 - 0.4
# Split by PARAM tbl_strata( data = df, strata = PARAMCD, .tbl_fun = ~ tbl_baseline_chg( data = .x, baseline_level = "Baseline", by = "TRTA", denominator = cards::ADSL ), .combine_with = "tbl_stack", .combine_args = list(group_header = NULL, quiet = TRUE) ) |> tbl_split_by_rows(variable_level = ends_with("lbl")) #> Converting column "TRTA" to a factor. #> Converting column "TRTA" to a factor. #> #> ── Printing 2 Tables ── #> #> ── Table 1 of 2: K #> #> ── Table 2 of 2: SODIUM