hb_data {historicalborrow} | R Documentation |
Standardize data
Description
Standardize a tidy input dataset.
Usage
hb_data(
data,
response,
study,
study_reference,
group,
group_reference,
patient,
covariates
)
Arguments
data |
A tidy data frame or |
response |
Character of length 1,
name of the column in |
study |
Character of length 1,
name of the column in |
study_reference |
Atomic of length 1,
element of the |
group |
Character of length 1,
name of the column in |
group_reference |
Atomic of length 1,
element of the |
patient |
Character of length 1,
name of the column in |
covariates |
Character vector of column names
in |
Details
Users do not normally need to call this function. It mainly serves exposes the indexing behavior of studies and group levels to aid in interpreting summary tables.
Value
A standardized tidy data frame with one row per patient and the following columns:
-
response
: continuous response/outcome variable. (Should be change from baseline of an outcome of interest.) -
study_label
: human-readable label of the study. -
study
: integer study index with the max index equal to the current study (atstudy_reference
). -
group_label
: human-readable group label (e.g. treatment arm name). -
group
: integer group index with an index of 1 equal to the control group (atgroup_reference
). -
patient_label
: original patient ID. -
patient
: integer patient index. -
covariate_*
: baseline covariate columns.
See Also
Other data:
hb_s_tau()
Examples
data <- hb_sim_independent(n_continuous = 1, n_study = 2)$data
data <- dplyr::select(
data,
study,
group,
patient,
response,
tidyselect::everything()
)
colnames(data) <- c("trial", "arm", "subject", "change", "cov1", "cov2")
data$trial <- paste0("trial", data$trial)
data$arm <- paste0("arm", data$arm)
hb_data(
data = data,
response = "change",
study = "trial",
study_reference = "trial1",
group = "arm",
group_reference = "arm1",
patient = "subject",
covariates = c("cov1", "cov2")
)