ard_tabulate_abnormal: ARD Abnormality Counts

View source: R/ard_tabulate_abnormal.R

ard_tabulate_abnormalR Documentation

ARD Abnormality Counts

Description

Function counts participants with abnormal analysis range values.

For each abnormality specified via the abnormal parameter (e.g. Low or High), statistic n is calculated as the number of patients with this abnormality recorded, and statistic N is calculated as the total number of patients with at least one post-baseline assessment. p is calculated as n / N. If excl_baseline_abn=TRUE then participants with abnormality at baseline are excluded from all statistic calculations.

Usage

ard_tabulate_abnormal(
  data,
  postbaseline,
  baseline,
  id = NULL,
  by = NULL,
  strata = NULL,
  abnormal = list(Low = "LOW", High = "HIGH"),
  excl_baseline_abn = TRUE,
  quiet = FALSE
)

Arguments

data

(data.frame)
a data frame.

postbaseline

(tidy-select)
column name of post-baseline reference range indicator variable.

baseline

(tidy-select)
column name of baseline reference range indicator variable.

id

(tidy-select)
column name used to identify unique participants in data. If NULL, each row in data is assumed to correspond to a unique participants.

by, strata

(tidy-select)
columns to tabulate by/stratify by for summary statistic calculation. Arguments are similar, but with an important distinction:

by: results are calculated for all combinations of the columns specified, including unobserved combinations and unobserved factor levels.

strata: results are calculated for all observed combinations of the columns specified.

Arguments may be used in conjunction with one another.

abnormal

(list)
a named list of abnormalities to assess for. Each element should specify all levels of postbaseline/baseline that should be included when assessing for a given abnormality, with the name specifying the name of the abnormality. Any levels specified but not present in the data are ignored.

excl_baseline_abn

(logical)
whether participants with baseline abnormality should be excluded from calculations. Defaults to TRUE.

quiet

(scalar logical)
logical indicating whether to suppress additional messaging. Default is FALSE.

Value

an ARD data frame of class 'card'

Examples

# Load Data -------------------
set.seed(1)
adlb <- cards::ADLB
adlb$BNRIND <- ifelse(
  adlb$BNRIND != "N",
  sample(c("LOW", "LOW LOW", "HIGH", "HIGH HIGH"), nrow(adlb), replace = TRUE),
  "NORMAL"
)

# Example 1 -------------------
adlb |>
  ard_tabulate_abnormal(
    postbaseline = LBNRIND, baseline = BNRIND, id = USUBJID, by = TRTA,
    abnormal = list(Low = c("LOW", "LOW LOW"), High = c("HIGH", "HIGH HIGH"))
  )

cardx documentation built on Aug. 27, 2025, 5:11 p.m.