#The commands below assume that the lungcancer data set has been stored

# in the dataframe "lungcancer" and that the survival library has been attached

# (cf. the R commands to the lectures of week 39)

 

#Compute and make Kaplan-Meier plot with standard confidence intervals for all data:

fit.lung<- survfit(Surv(time,cens)~1, data=lungcancer, conf.type="plain")

plot(fit.lung, mark.time=F, xlab="Months")

 

#Compute and make Kaplan-Meier plot with log-minus-log transformed confidence intervals for all data:

fit.lung<- survfit(Surv(time,cens)~1, data=lungcancer, conf.type="log-log")

plot(fit.lung, mark.time=F, xlab="Months")

 

#Write a short output (including median survival time with confidence limits);

print(fit.lung)

 

#Write a more extensive output:

summary(fit.lung)

 

#Compute and make separate Kaplan-Meier plots for males and females:

fit.lung<- survfit(Surv(time,cens)~sex, data=lungcancer, conf.type="plain")

plot(fit.lung, mark.time=F, lty=c(1,4), xlab="Months")