Convert dataframe to include survival (Surv) objects
Convert dataframe to include survival (Surv) objects
Within a dataframe, paired numeric fields that use a "_lo" and "_hi" suffix naming convention (e.g., "conc_lo" "conc_hi") are combined into a single Surv object (e.g., "conc") using the "interval2" option provided by through the survival::Surv(conc_lo, conc_hi, type = "interval2") syntax.
makeSurvDF(df, suf_lo ="_lo", suf_hi ="_hi")
Arguments
df: name of data frame
suf_lo: Column name suffix for "lo" values. Default = "_lo"
suf_hi: Column name suffix for "hi" values. Default = "_hi"
Returns
dataframe with Surv fields
Details
Converting fields to Surv objects works with field pairs that have a "_lo" and "_hi" suffix naming convention. The numeric value for "_hi" must be greater than or equal to the "_lo" value. Source data that violate this requirement are set to NA with a summary report outputted to the console.
The user can specify their own values for the lo/hi suffixes or use the defaults.