我正在使用R对电池进行存活率分析。虽然我没问题让它正常工作,但是当我尝试修剪曲线的尾部(那里处于危险中的人数非常少)时,我失去了存活率桌子。
# --functioning code without tail removed
library(survival)
dataset <- read.csv("C:\\Users\\Michael McCarthy\\Desktop\\testing\\new_format.csv",
header = TRUE)
mysurv <- Surv(time=dataset$length_of_time_active_days, event=dataset$censored)
myfit <- survfit(mysurv~dataset$hardware_type)
ggsurvplot(myfit, size=1, data=dataset,
font.main = 10, font.x = 10, font.y = 10, font.tickslab = 10,
legend = "bottom", legend.title = "Control Units",
conf.int = FALSE, ggtheme = theme_bw(),
risk.table = TRUE, risk.table.y.text.col = TRUE, tables.height=.35,
surv.plot.width=1, fun = function(y) y*100,
ylab='Survival %', xlab= 'Months with Customers',
risk.table.y.text = FALSE)
# -- code where tail is removed
library(survival)
dataset <- read.csv("C:\\Users\\Michael McCarthy\\Desktop\\For deleting\\new_format.csv",
header = TRUE)
mysurv <- Surv(time=dataset$length_of_time_active_days, event=dataset$censored)
myfit <- survfit(mysurv~dataset$hardware_type)
aa <- subset(surv_summary(myfit,data = dataset), n.risk>=1000)
ggsurvplot(aa, size=1, data=dataset,
font.main = 10, font.x = 10, font.y = 10, font.tickslab = 10,
legend = "bottom", legend.title = "Control Units",
conf.int = FALSE, ggtheme = theme_bw(),
risk.table = TRUE, risk.table.y.text.col = TRUE, tables.height=.35,
surv.plot.width=1, fun = function(y) y*100,
ylab='Survival %', xlab= 'Months with Customers',
risk.table.y.text = FALSE)