tbl_baseline_chg: Change from Baseline

View source: R/tbl_baseline_chg.R

tbl_baseline_chgR Documentation

Change from Baseline

Description

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

Usage

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 = {gtsummary::style_number(n)})",
  ...
)

Arguments

data

(data.frame)
A data frame.

baseline_level

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

denominator

(string)
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

(string)
String identifying the unique subjects. Default is 'USUBJID'.

visit

(string)
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

(string)
String identifying the visit or analysis sequence number. Default is 'AVISITN'.

analysis_variable

(string)
String identifying the analysis values. Default is 'AVAL'.

change_variable

(string)
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()

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

tbl_baseline_chg(
  data = df,
  baseline_level = "Baseline",
  by = "TRTA",
  denominator = cards::ADSL
)

tbl_baseline_chg(
  data = df,
  baseline_level = "Baseline",
  by = "TRTA",
  denominator = cards::ADSL
) |>
  add_overall(last = TRUE, col_label = "All Participants")


crane documentation built on Aug. 30, 2025, 1:12 a.m.