I use the ggsurvplot from survminer package in R to plot Kaplan-Meir curves. Here is the code and the following error:
library(ggplot2)
library(survival)
library(survminer)
km_fit_2cohorts <- survival::survfit(Surv(time_event_M, indic_Death) ~ cohort, data = data_2cohorts)
survminer::ggsurvplot(km_fit_2cohorts, risk.table = TRUE, surv.scale = "percent")
Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto), : VECTOR_ELT() can only be applied to a 'list', not a 'NULL' In addition: Warning message: Vectorized input to
element_text()
is not officially supported. Results may be unexpected or may change in future versions of ggplot2.
My R version : 4.0.2 packages versions: [1] stringr_1.4.0 survminer_0.4.8 ggpubr_0.4.0 survival_3.2-3 tidyr_1.1.2 ggplot2_3.3.2 dplyr_1.0.2 plyr_1.8.6 readr_1.3.1
In fact when testing the same code in another R: R version : 4.0.2 packages versions: [1] survminer_0.4.8 ggpubr_0.4.0 survival_3.1-12 tidyr_1.1.0 ggplot2_3.3.2 dplyr_1.0.0 plyr_1.8.6 readr_1.3.1, there is the same warning, but the plot is well printed. The R version is identical, as well as ggplot2 and survminer, but survival version is older.
So it seems that with the new versions of survival package, ggsurvplot()
does not work anymore, which is very annoying. I cannot change easily the packages version on the platform where I work. Do you know a solution for future use of ggsurvplot()
with last survival versions?
Thanks much for your help.