This is not so much a question rather than a bug report which I have now raised on GitHub. I am posting it here because lots of people are using SO rather than GitHub to get help. And maybe someone of you has found/ will find a workaround for it.
survminer::ggsurvplot
doesn't seem to draw risk tables any longer. It must have been a recent update with something (I cannot say of what!), because it used to work until some time ago (I cannot say when it stopped working).
This is a reprex of the example code in ?ggsurvplot
!!! I just added risk.table = T
.
library(survminer)
#> Loading required package: ggplot2
#> Loading required package: ggpubr
library(survival)
#>
#> Attaching package: 'survival'
#> The following object is masked from 'package:survminer':
#>
#> myeloma
fit <- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data = lung, risk.table = T)
#> Error in as.character(call[[1]]): cannot coerce type 'closure' to vector of type 'character'
Created on 2024-03-14 with reprex v2.1.0
Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.3.2 (2023-10-31)
#> os macOS Big Sur 11.7.6
#> system x86_64, darwin20
#> ui X11
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> ggplot2 * 3.4.4.9000 2023-11-19 [1] local
#> ggpubr * 0.6.0 2023-02-10 [1] CRAN (R 4.3.0)
#> survival * 3.5-7 2023-08-14 [1] CRAN (R 4.3.2)
#> survminer * 0.4.9 2021-03-09 [1] CRAN (R 4.3.0)
#> ──────────────────────────────────────────────────────────────────────────────
Thanks user Stefan who reminded me of the importance of always keeping all your packages up to date! (I also only then realised that I was still running ggplot2's Dev version).
suppressMessages({
library(survminer)
library(survival)})
fit <- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data = lung, risk.table = T)
Created on 2024-03-14 with reprex v2.1.0
Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.3.2 (2023-10-31)
#> os macOS Big Sur 11.7.6
#> system x86_64, darwin20
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> ggplot2 * 3.5.0 2024-02-23 [1] CRAN (R 4.3.2)
#> ggpubr * 0.6.0 2023-02-10 [1] CRAN (R 4.3.0)
#> survival * 3.5-8 2024-02-14 [1] CRAN (R 4.3.2)
#> survminer * 0.4.9 2021-03-09 [1] CRAN (R 4.3.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
#>
#> ──────────────────────────────────────────────────────────────────────────────