服务热线
178 0020 3020
##R2-6
install.packages("ggpubr") install.packages("survminer") library(ggplot2) library(ggpubr) library(magrittr) library(survminer) library(survival) #load necessary packages
data(package = "survival") str(lung) ??lung #explore data structure
?survfit
attach(lung) mysurv <- Surv(time,status) kmfit1 <- survfit(mysurv~1) summary(kmfit1) plot(kmfit1)
## Create Kaplan-Meier curve stratified by sex km.by.sex <- survfit(Surv(time, status) ~ sex, data = lung, conf.type = "log-log")
plot(km.by.sex) ## Basic survival curves ggsurvplot(fit, data = lung,pval=TRUE,conf.int=TRUE,surv.median.line = "hv", legend.labs=c("Male","Female"),legend.title="SEX", ncensor.plot=TRUE,risk.table=TRUE,risk.table.col="sex", title = "R2-05")
附件