summarize_change {tern} | R Documentation |
Summarize the change from baseline or absolute baseline values
Description
The primary analysis variable .var
indicates the numerical change from baseline results,
and additional required secondary analysis variables are value
and baseline_flag
.
Depending on the baseline flag, either the absolute baseline values (at baseline)
or the change from baseline values (post-baseline) are then summarized.
Usage
summarize_change(
lyt,
vars,
variables,
na_str = default_na_str(),
nested = TRUE,
...,
table_names = vars,
.stats = c("n", "mean_sd", "median", "range"),
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_change_from_baseline(df, .var, variables, na.rm = TRUE, ...)
a_change_from_baseline(df, .var, variables, na.rm = TRUE, ...)
Arguments
lyt |
( |
vars |
( |
variables |
(named |
na_str |
( |
nested |
( |
... |
additional arguments for the lower level functions. |
table_names |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
df |
( |
.var |
( |
na.rm |
( |
Value
-
summarize_change()
returns a layout object suitable for passing to further layouting functions, or tortables::build_table()
. Adding this function to anrtable
layout will add formatted rows containing the statistics froms_change_from_baseline()
to the table layout.
-
s_change_from_baseline()
returns the same values returned bys_summary.numeric()
.
-
a_change_from_baseline()
returns the corresponding list with formattedrtables::CellValue()
.
Functions
-
summarize_change()
: Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper forrtables::analyze()
. -
s_change_from_baseline()
: Statistics function that summarizes baseline or post-baseline visits. -
a_change_from_baseline()
: Formatted analysis function which is used asafun
insummarize_change()
.
Note
To be used after a split on visits in the layout, such that each data subset only contains either baseline or post-baseline data.
The data in df
must be either all be from baseline or post-baseline visits. Otherwise
an error will be thrown.
Examples
library(dplyr)
## Fabricate dataset
dta_test <- data.frame(
USUBJID = rep(1:6, each = 3),
AVISIT = rep(paste0("V", 1:3), 6),
ARM = rep(LETTERS[1:3], rep(6, 3)),
AVAL = c(9:1, rep(NA, 9))
) %>%
mutate(ABLFLL = AVISIT == "V1") %>%
group_by(USUBJID) %>%
mutate(
BLVAL = AVAL[ABLFLL],
CHG = AVAL - BLVAL
) %>%
ungroup()
results <- basic_table() %>%
split_cols_by("ARM") %>%
split_rows_by("AVISIT") %>%
summarize_change("CHG", variables = list(value = "AVAL", baseline_flag = "ABLFLL")) %>%
build_table(dta_test)
results