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)})",
...
)(data.frame)
A data frame.
(string)
String identifying baseline level in the visit variable.
(data.frame)
Data set used to compute the header counts (typically ADSL).
(tidy-select)
A single column from data. Summary statistics will be stratified by this variable.
Default is NULL.
(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.
(tidy-select)
String identifying the unique subjects. Default is 'USUBJID'.
(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.
(tidy-select)
String identifying the visit or analysis sequence number. Default is
'AVISITN'.
(tidy-select)
String identifying the analysis values. Default is 'AVAL'.
(tidy-select)
String identifying the change from baseline values. Default is 'CHG'.
(tbl_summary, tbl_svysummary, tbl_continuous, tbl_custom_summary)
A stratified 'gtsummary' table
(scalar logical)
Logical indicator to display overall column last in table.
Default is FALSE, which will display overall column first.
(string)
String indicating the column label. Default is "**Overall** \nN = {style_number(N)}"
These dots are for future extensions and must be empty.
A gtsummary table.
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.
Value at Visit
Change from Baseline
Value at Visit
Change from Baseline
Value at Visit
Change from Baseline
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.
Value at Visit
Change from Baseline
Value at Visit
Change from Baseline
Value at Visit
Change from Baseline
Value at Visit
Change from Baseline
# 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