2

I am trying to draw survival curves and associated risk tables using the survminer package. I am unable to draw the risk tables, all other elements work fine. RStudio either throws the following error:

Error in bl_make_text_box(token, drawing_context$gp, drawing_context$yoff_pt) : function 'Rcpp_precious_remove' not provided by package 'Rcpp'

or gets stuck and becomes unresponsive.

I have installed and loaded the Rcpp package without success, and I have also restarted R and cleared the workspace. This happens with multiple datasets. An example is the code below from the survminer cheatsheet which gives me the same problem. Any advice much appreciated! I suspect it's something to do with my environment but I can't figure out what.

library("survival")
fit <- survfit(Surv(time,status)
               ~ sex, data = lung)
library("survminer")

ggsurvplot(fit, data = lung,
           conf.int = TRUE,
           pval = TRUE,
           fun = "pct",
           risk.table = TRUE,
           size = 1,
           linetype = "strata",
           palette = c("#E7B800",
                       "#2E9FDF"),
           legend = "bottom",
           legend.title = "Sex",
           legend.labs = c("Male",
                           "Female"))

EDIT as requested

> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] survminer_0.4.9 ggpubr_0.4.0    ggplot2_3.3.3   survival_3.2-11

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6        lattice_0.20-44   tidyr_1.1.3       zoo_1.8-9         assertthat_0.2.1  digest_0.6.27     utf8_1.2.1        R6_2.5.0         
 [9] cellranger_1.1.0  backports_1.2.1   evaluate_0.14     pillar_1.6.1      rlang_0.4.11      curl_4.3.1        readxl_1.3.1      data.table_1.14.0
[17] car_3.0-11        Matrix_1.3-3      rmarkdown_2.8     labeling_0.4.2    splines_4.1.0     stringr_1.4.0     foreign_0.8-81    munsell_0.5.0    
[25] gridtext_0.1.4    tinytex_0.31      broom_0.7.8       compiler_4.1.0    xfun_0.23         pkgconfig_2.0.3   htmltools_0.5.1.1 ggtext_0.1.1     
[33] tidyselect_1.1.1  tibble_3.1.2      gridExtra_2.3     km.ci_0.5-2       rio_0.5.27        fansi_0.4.2       crayon_1.4.1      dplyr_1.0.6      
[41] withr_2.4.2       grid_4.1.0        xtable_1.8-4      gtable_0.3.0      lifecycle_1.0.0   DBI_1.1.1         magrittr_2.0.1    KMsurv_0.1-5     
[49] scales_1.1.1      zip_2.2.0         stringi_1.6.1     carData_3.0-4     farver_2.1.0      ggsignif_0.6.2    xml2_1.3.2        ellipsis_0.3.2   
[57] survMisc_0.5.5    generics_0.1.0    vctrs_0.3.8       openxlsx_4.2.4    tools_4.1.0       forcats_0.5.1     glue_1.4.2        markdown_1.1     
[65] purrr_0.3.4       hms_1.1.0         abind_1.4-5       yaml_2.2.1        colorspace_2.0-1  rstatix_0.7.0     knitr_1.33        haven_2.4.1     

user20650
  • 24,654
  • 5
  • 56
  • 91
Alex Wood
  • 21
  • 2
  • Your code runs okay for me. Can you [edit](https://stackoverflow.com/posts/68372927/edit) your question with the results of `sessionInfo()` please. – user20650 Jul 14 '21 at 17:19
  • Thanks. We have few differences in package versions: The ones that might make a difference are ggplot2_3.3.5, Rcpp_1.0.7. So try upgrading. – user20650 Jul 16 '21 at 21:49

1 Answers1

1

The problematic function bl_make_text_box() is from gridtext. So likely you have a recent version or gridtext compiled against an older version of Rccp. Try updating Rccp to version 1.0.7 and with a bit of hope it should work:

install.packages("Rcpp")

For reference same problem described on Rccp mailing list which can summarised with

TL;DR: update your library.

Marcelo Avila
  • 2,314
  • 1
  • 14
  • 22