choose_standard_refpat.Rd
Based on either most common or reference factor levels in sample for categorical variable, or median/mean for continuous variables.
choose_standard_refpat( col, contin_action = c("median", "mean"), categ_action = c("most_common", "reference") )
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 |
Returns single either numeric or character value for a specific col
# Used on single column: choose_standard_refpat(dat_mds_synth$karnofsk_allo1, categ_action = "most_common") #> [1] >=90 #> Levels: >=90 80 <=70 # 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[] #> karnofsk_allo1 age_allo1_decades #> 1: >=90 5.601