choose_standard_refpat: Choose standard reference patient to predict

View source: R/illustrative-analysis-helpers.R

choose_standard_refpatR Documentation

Choose standard reference patient to predict

Description

Based on either most common or reference factor levels in sample for categorical variable, or median/mean for continuous variables.

Usage

choose_standard_refpat(
  col,
  contin_action = c("median", "mean"),
  categ_action = c("most_common", "reference")
)

Arguments

col

A vector, generally corresponding to a dataframe column

contin_action

Character, choosing whether to select mean or median value for a continuous variable

categ_action

Character, choosing whether to select most common or reference factor levels for a categorical variable

Value

Returns single either numeric or character value for a specific col

Examples

# Used on single column:
choose_standard_refpat(dat_mds_synth$karnofsk_allo1, categ_action = "most_common")

# Used on many columns
dat <- data.table::data.table(dat_mds_synth)
ref_pat <- dat[, lapply(.SD, function(col) {
CauseSpecCovarMI::choose_standard_refpat(col, "median", "reference") 
}), .SD = c("karnofsk_allo1", "age_allo1_decades")]

ref_pat[]


survival-lumc/CauseSpecCovarMI documentation built on June 16, 2022, 9:51 a.m.