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]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to