This function is used to compute the numeric variable summary statistic grouped by categorical variable.
Usage
compute_score_summary(
.data,
wideFormat = TRUE,
scoreVar,
groupVar = "DX",
filterGroup = NULL,
groupVar1 = NULL
)Arguments
- .data
Data.frame
- wideFormat
A Boolean value whether the input data.frame is in a
wideorlongformat, Default: TRUE- scoreVar
Character vector of variable(s) that contain the actual score/numeric values
When
wideFormatisFALSE(i.e., for a long format data),scoreVarmust be a length of one character vector of variable name that contains the score/numeric values.- groupVar
Group variable, Default: 'DX'
- filterGroup
Filter value of group variable
groupVar, Default: NULL Only applicable if thegroupVaris a length of one character vector.- groupVar1
Additional grouping variable, only applicable for
longformat data.frame.
Value
A data.frame with the following columns:
groupVar: Grouping variableVAR: Score/numeric variable nameN: Number of non-missing observationMEAN: Mean scoreSD: Standard deviation value
Details
All computed summary statistic are based on non-missing observation.
The result summary will be filter by the corresponding filterGroup value(s).
See also
compute_baseline_score_summary()
vignette(topic = "ADNIMERGE2-PACC-SCORE", package = "ADNIMERGE2")
Examples
if (FALSE) { # \dontrun{
# For long format data
# Suppose we wanted to compute the baseline summary score of
# all available assessments in \code{ADNIMERGE2::ADQS}
# By baseline diagnosis status.
library(tidyverse)
library(ADNIMERGE2)
long_format_example <- ADNIMERGE2::ADQS %>%
filter(ABLFL %in% "Y") %>%
# Check there is only one baseline record per assessment type per subject
ADNIMERGE2::assert_uniq(USUBJID, PARAMCD)
compute_score_summary(
.data = long_format_example,
wideFormat = FALSE,
scoreVar = "AVAL",
groupVar1 = "PARAMCD",
groupVar = "DX",
filterGroup = NULL
)
# For only cognitive normal (CN) subjects
compute_score_summary(
.data = long_format_example,
wideFormat = FALSE,
scoreVar = "AVAL",
groupVar1 = "PARAMCD",
groupVar = "DX",
filterGroup = "CN"
)
# For wide format data
# Suppose we wanted to compute the baseline summary statistic of
# \code{AGE}, \code{BMI}, \code{ADASTT11} and \code{ADASTT13}
wide_format_example <- ADNIMERGE2::ADSL %>%
filter(ENRLFL %in% "Y")
# By baseline diagnostics status
compute_score_summary(
.data = wide_format_example,
wideFormat = TRUE,
scoreVar = c("AGE", "BMI", "ADASTT11", "ADASTT13"),
groupVar1 = NULL,
groupVar = "DX",
filterGroup = NULL
)
compute_score_summary(
.data = wide_format_example,
wideFormat = TRUE,
scoreVar = c("AGE", "BMI", "ADASTT11", "ADASTT13"),
groupVar1 = NULL,
groupVar = "DX",
filterGroup = "CN"
)
# By SEX
compute_score_summary(
.data = wide_format_example,
wideFormat = TRUE,
scoreVar = c("AGE", "BMI", "ADASTT11", "ADASTT13"),
groupVar1 = NULL,
groupVar = "SEX",
filterGroup = NULL
)
} # }
