Reputation: 23
i'm using the survminer package to create a Kaplan-Meier-Curve in R, which is working pretty well:
plotUICC=survfit(Surv(as.numeric(myData$eventtime),event=myData$eventtype)~myData$UICC, data = myData)
ggsurvplot(plotUICC,data=myData, risk.table = FALSE,pval = TRUE,conf.int = FALSE,legend.labs = c("UICC I", "UICC II"),legend = c(0.25, 0.26),legend.title = "",xlab = "Time in Months"))
Kaplan Meier Curve created with the Cod above
I would like to change the "+" as censored event and use an simple "|" instead. Unfortunately neither help(ggsurvplot) nor google could help me.
These are the loaded packeges:
other attached packages:
[1] ggthemes_3.4.0 survminer_0.3.1 ggpubr_0.1.2 ggplot2_2.2.1 survival_2.40-1
[6] readxl_0.1.1 gridExtra_2.2.1
Upvotes: 1
Views: 5452
Reputation: 305
A minimal working example is the following:
library(survminer)
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
p1 <- ggsurvplot(fit, data = lung)
Ideally, one would like to change the shape of the censors e.g. like so:
p2 <- ggsurvplot(fit, data = lung, censor.shape=124)
I have found no way to do this with the original survminer package. In a fork of survminer , I have implemented this behaviour, so that the following plot is produced:
Acceptable values for censor.shape can be found here: http://sape.inf.usi.ch/quick-reference/ggplot2/shape
I haven't tested this thoroughly, but this extension is already very useful for me. The "+" censors have bothered me for some time...
Edit: This suggestion was now merged, the development version of ggsurvplot now accepts censor.shape and censor.size arguments:
ggsurvplot(fit, data = lung, censor.shape="|", censor.size = 4)
Upvotes: 5