我想创建一个看起来与此link (Researchgate)的Kaplan Meier曲线相似的Kaplan meier曲线
我有2个独立变量:1.性别(1 =男性,2 =女性)2.危险因素(1 =存在0 =不存在) Kaplan meier曲线的危险类别应按性别和第二个危险因素进行划分。
Curve 1 : Male + Risk factor present
Curve 2 : Male + No risk factor
Curve 3: Female + risk factor present
Curve 4: Female+ No risk factor
提前感谢您的帮助!
答案 0 :(得分:2)
# 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
)