##pdf("flysurv.pdf") flysurv <- read.table("http://www.stat.ufl.edu/~winner/data/flysurv1.dat", col.names=c("trt", "time", "censor")) attach(flysurv) # Load the survival analysis package library(survival) # Print out the survival times, censored values have a "+" next to them (Surv must be spelled exactly this way) Surv(time, censor==0) # Obtain survival tables and curves by regimen surv.byreg <- survfit(Surv(time, censor==0)~trt) summary(surv.byreg) plot(surv.byreg) # Conduct the Log-Rank test to compare survival curves survdiff(Surv(time,censor==0)~trt) ##dev.off()