Reputation: 63
I'd like to create a Kaplan meier curve which looks similar to the Kaplan Meier curve of this link (Researchgate)
I got 2 seperate variables: 1. gender (1=male, 2 = female) 2. risk factor (1=present 0= not present) The risk groups of the Kaplan meier curve should be divided by sex and a second riskfactor.
Curve 1 : Male + Risk factor present
Curve 2 : Male + No risk factor
Curve 3: Female + risk factor present
Curve 4: Female+ No risk factor
Thank you in advance for your help!
Upvotes: 2
Views: 1513
Reputation: 63
I found the solution: http://www.sthda.com/english/wiki/survminer-r-package-survival-data-analysis-and-visualization#survival-curves-with-multiple-groups
# Fit (complexe) survival curves
#++++++++++++++++++++++++++++++++++++
require("survival")
fit2 <- survfit( Surv(time, status) ~ gender + risk factor,
data = colon )
# Visualize
#++++++++++++++++++++++++++++++++++++
# Visualize: add p-value, chang y limits
# change color using brewer palette
ggsurvplot(fit2, pval = TRUE,
break.time.by = 800,
risk.table = TRUE,
risk.table.height = 0.5#Useful when you have multiple groups
)
Upvotes: 2