我有一个这样的数据框
df = data.frame(time=c(1,2,3,4,1), event=c(1,1,0,0,1))
我想创建一条生存曲线
library(survival)
km <- survfit(Surv(time,event) ~ 1, data = df)
library("survminer")
ggsurvplot(km, color = "#2E9FDF",
data =df,
ncensor.plot = TRUE)
可以,但是要警告
Warning message:
Now, to change color palette, use the argument palette= '#2E9FDF' instead of color = '#2E9FDF'
我改变
ggsurvplot(km, palette = "#2E9FDF",
data =df,
ncensor.plot = TRUE)
我们有错误
Error in grDevices::col2rgb(colour, TRUE) : invalid color name "strata"
问题出在ncensor.plot
中。当我们删除它时没有错误
ggsurvplot(km, palette = "#2E9FDF",
data =df)
如何修复Error in grDevices::col2rgb(colour, TRUE)