abnormal | R Documentation |
Primary analysis variable .var
indicates the abnormal range result (character
or factor
)
and additional analysis variables are id
(character
or factor
) and baseline
(character
or
factor
). For each direction specified in abnormal
(e.g. high or low) count patients in the
numerator and denominator as follows:
num
: The number of patients with this abnormality recorded while on treatment.
denom
: The number of patients with at least one post-baseline assessment.
count_abnormal(
lyt,
var,
abnormal = list(Low = "LOW", High = "HIGH"),
variables = list(id = "USUBJID", baseline = "BNRIND"),
exclude_base_abn = FALSE,
na_str = default_na_str(),
nested = TRUE,
...,
table_names = var,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_count_abnormal(
df,
.var,
abnormal = list(Low = "LOW", High = "HIGH"),
variables = list(id = "USUBJID", baseline = "BNRIND"),
exclude_base_abn = FALSE
)
a_count_abnormal(
df,
.var,
abnormal = list(Low = "LOW", High = "HIGH"),
variables = list(id = "USUBJID", baseline = "BNRIND"),
exclude_base_abn = FALSE
)
lyt |
( |
abnormal |
(named |
variables |
(named |
exclude_base_abn |
( |
na_str |
( |
nested |
( |
... |
additional arguments for the lower level functions. |
table_names |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
df |
( |
.var , var |
( |
count_abnormal()
returns a layout object suitable for passing to further layouting functions,
or to rtables::build_table()
. Adding this function to an rtable
layout will add formatted rows containing
the statistics from s_count_abnormal()
to the table layout.
s_count_abnormal()
returns the statistic fraction
which is a vector with num
and denom
counts of patients.
a_count_abnormal()
returns the corresponding list with formatted rtables::CellValue()
.
count_abnormal()
: Layout-creating function which can take statistics function arguments
and additional format arguments. This function is a wrapper for rtables::analyze()
.
s_count_abnormal()
: Statistics function which counts patients with abnormal range values
for a single abnormal
level.
a_count_abnormal()
: Formatted analysis function which is used as afun
in count_abnormal()
.
count_abnormal()
only works with a single variable containing multiple abnormal levels.
df
should be filtered to include only post-baseline records.
the denominator includes patients that might have other abnormal levels at baseline, and patients with missing baseline. Patients with these abnormalities at baseline can be optionally excluded from numerator and denominator.
library(dplyr)
df <- data.frame(
USUBJID = as.character(c(1, 1, 2, 2)),
ANRIND = factor(c("NORMAL", "LOW", "HIGH", "HIGH")),
BNRIND = factor(c("NORMAL", "NORMAL", "HIGH", "HIGH")),
ONTRTFL = c("", "Y", "", "Y"),
stringsAsFactors = FALSE
)
# Select only post-baseline records.
df <- df %>%
filter(ONTRTFL == "Y")
# Layout creating function.
basic_table() %>%
count_abnormal(var = "ANRIND", abnormal = list(high = "HIGH", low = "LOW")) %>%
build_table(df)
# Passing of statistics function and formatting arguments.
df2 <- data.frame(
ID = as.character(c(1, 1, 2, 2)),
RANGE = factor(c("NORMAL", "LOW", "HIGH", "HIGH")),
BL_RANGE = factor(c("NORMAL", "NORMAL", "HIGH", "HIGH")),
ONTRTFL = c("", "Y", "", "Y"),
stringsAsFactors = FALSE
)
# Select only post-baseline records.
df2 <- df2 %>%
filter(ONTRTFL == "Y")
basic_table() %>%
count_abnormal(
var = "RANGE",
abnormal = list(low = "LOW", high = "HIGH"),
variables = list(id = "ID", baseline = "BL_RANGE")
) %>%
build_table(df2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.