processSurvTerms | R Documentation |
Process survival curves terms to calculate survival curves
processSurvTerms(
clinical,
censoring,
event,
timeStart,
timeStop = NULL,
group = NULL,
formulaStr = NULL,
coxph = FALSE,
scale = "days",
followup = "days_to_last_followup",
survTime = NULL
)
clinical |
Data frame: clinical data |
censoring |
Character: censor using |
event |
Character: name of column containing time of the event of interest |
timeStart |
Character: name of column containing starting time of the interval or follow up time |
timeStop |
Character: name of column containing ending time of the interval (only relevant for interval censoring) |
group |
Character: group relative to each subject |
formulaStr |
Character: formula to use |
coxph |
Boolean: fit a Cox proportional hazards regression model? |
scale |
Character: rescale the survival time to |
followup |
Character: name of column containing follow up time |
survTime |
|
The event
time is only used to determine whether the event
has occurred (1
) or not (0
) in case of missing values.
If survTime = NULL
, survival times are obtained from the clinical
dataset according to the names given in timeStart
, timeStop
,
event
and followup
. This may become quite slow when used in a
loop. If the aforementioned variables are constant, consider running
getAttributesTime()
outside the loop and using its output via
the survTime
argument of this function (see Examples).
A list with a formula
object and a data frame with terms
needed to calculate survival curves
Other functions to analyse survival:
assignValuePerSubject()
,
getAttributesTime()
,
labelBasedOnCutoff()
,
optimalSurvivalCutoff()
,
plotSurvivalCurves()
,
plotSurvivalPvaluesByCutoff()
,
survdiffTerms()
,
survfit.survTerms()
,
testSurvival()
clinical <- read.table(text = "2549 NA ii female
840 NA i female
NA 1204 iv male
NA 383 iv female
1293 NA iii male
NA 1355 ii male")
names(clinical) <- c("patient.days_to_last_followup",
"patient.days_to_death",
"patient.stage_event.pathologic_stage",
"patient.gender")
timeStart <- "days_to_death"
event <- "days_to_death"
formulaStr <- "patient.stage_event.pathologic_stage + patient.gender"
survTerms <- processSurvTerms(clinical, censoring="right", event, timeStart,
formulaStr=formulaStr)
# If running multiple times, consider calculating survTime only once
survTime <- getAttributesTime(clinical, event, timeStart)
for (i in seq(5)) {
survTerms <- processSurvTerms(clinical, censoring="right", event,
timeStart, formulaStr=formulaStr,
survTime=survTime)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.