[R] Adjusted survival curves
Ted Beginner (RStudio)
r-subscribe at mail.ru
Mon Oct 9 21:54:08 CEST 2017
Adjusted survival curves. (Sample code here: https://rpubs.com/daspringate/survival )
Deep gratitude to Moderator/Admin!
At David Winsemius prompt, more elegant working code:Thanks, Ted :)
library(survival)
library(survminer)
df<-read.csv("F:/R/data/edgr-orig.csv", header = TRUE, sep = ";")
df2 <- df
df2[,c('treatment', 'age', 'sex', 'stage')] <- lapply(df2[,c('treatment', 'age', 'sex', 'stage')], factor)
model <- coxph (Surv(time = start,
time2 = stop,
event = censor)~ treatment + age + sex + stage, data = df2)
treat <- with(df2,
data.frame(
treatment = levels(treatment),
age = rep(levels(age)[1], 2),
sex = rep(levels(sex)[1], 2),
stage = rep(levels(stage)[1], 2)))
plot(survfit(model, newdata = treat),
las=1,
xscale = 1.00,
conf.int = TRUE,
xlab = "Months after diagnosis",
ylab = "Proportion survived",
col = c("red", "green"))
[[alternative HTML version deleted]]
More information about the R-help
mailing list