Advanced tool for preparing outcome variables for various types of survival analysis including overall survival, cause-specific, competing risks, progression-free survival, and multistate models.
Usage
outcomeorganizer(
data,
outcome,
outcomeLevel,
recurrence,
recurrenceLevel,
patientID,
analysistype = "os",
multievent = FALSE,
dod,
dooc,
awd,
awod,
useHierarchy = FALSE,
eventPriority = 1,
intervalCensoring = FALSE,
intervalStart,
intervalEnd,
adminCensoring = FALSE,
adminDate,
outputTable = FALSE,
diagnostics = FALSE,
visualization = FALSE,
showNaturalSummary = FALSE,
showGlossary = FALSE
)Arguments
- data
The data as a data frame.
- outcome
The primary outcome variable to be recoded for survival analysis (e.g., vital status).
- outcomeLevel
The level of the outcome variable that represents the event of interest (e.g., "Death", "Relapse").
- recurrence
Variable indicating disease recurrence or progression (for RFS/PFS/DFS analyses).
- recurrenceLevel
The level indicating recurrence or progression has occurred.
- patientID
Patient identifier for handling multiple records or applying event hierarchies.
- analysistype
The type of survival analysis to prepare the outcome for.
- multievent
If true, allows for multiple event types (e.g., death from disease vs death from other causes).
- dod
The level representing death from the disease of interest.
- dooc
The level representing death from causes other than the disease of interest.
- awd
The level representing patients who are alive but have the disease.
- awod
The level representing patients who are alive and disease-free.
- useHierarchy
If true, applies a hierarchy when multiple events occur for the same patient.
- eventPriority
The event code (e.g., 1, 2) that takes precedence when multiple events occur.
- intervalCensoring
If true, prepares data for interval-censored analysis where exact event times are unknown.
- intervalStart
Variable containing the start of the interval when the event might have occurred.
- intervalEnd
Variable containing the end of the interval when the event might have occurred.
- adminCensoring
If true, applies administrative censoring at a specified date.
- adminDate
Variable containing the administrative censoring date.
- outputTable
If true, displays a table showing the frequency of each recoded outcome value.
- diagnostics
If true, displays diagnostic information about the recoding process.
- visualization
If true, displays a visualization of the distribution of recoded outcomes.
- showNaturalSummary
Display a plain-language summary of the recoding suitable for copying to reports.
- showGlossary
Display definitions of survival analysis terms.
Value
A results object containing:
results$todo | a html | ||||
results$summary | a html | ||||
results$outputTable | a table | ||||
results$diagnosticsTable | a table | ||||
results$outcomeViz | an image | ||||
results$naturalSummary | a html | ||||
results$glossary | a html | ||||
results$addOutcome | an output |
Tables can be converted to data frames with asDF or as.data.frame. For example:
results$outputTable$asDF
as.data.frame(results$outputTable)
Examples
# \donttest{
# Example 1: Overall survival analysis
data('lung', package = 'survival')
outcomeorganizer(
data = lung,
outcome = status,
outcomeLevel = 2,
analysistype = 'os',
addOutcome = TRUE
)
# Example 2: Competing risks (disease death vs other death)
# Create example data with multiple event types
mydata <- data.frame(
vital_status = factor(c('Alive_NED', 'Alive_Disease', 'Dead_Disease', 'Dead_Other')),
time = c(10, 15, 20, 25)
)
outcomeorganizer(
data = mydata,
outcome = vital_status,
analysistype = 'compete',
multievent = TRUE,
dod = 'Dead_Disease',
dooc = 'Dead_Other',
awd = 'Alive_Disease',
awod = 'Alive_NED',
addOutcome = TRUE
)
# Example 3: Progression-free survival with recurrence
mydata <- data.frame(
vital = factor(c('Alive', 'Alive', 'Dead', 'Alive')),
recurrence = factor(c('No', 'Yes', 'No', 'No')),
time = c(10, 15, 20, 25)
)
outcomeorganizer(
data = mydata,
outcome = vital,
outcomeLevel = 'Dead',
recurrence = recurrence,
recurrenceLevel = 'Yes',
analysistype = 'pfs',
addOutcome = TRUE
)
# }