survminer icon indicating copy to clipboard operation
survminer copied to clipboard

Missing at risk table using ggsurvplot_df

Open wnilesanderson opened this issue 5 years ago • 2 comments

Expected behavior

When I use ggsurvplot(survivalobject, risk.table = TRUE) I see a nice graph with associated at risk table. In fact, one of my personal reasons for using survminer is the nicely formatted and placed at risk table.

Another option for creating the curve is to generate a summary table using surv_summary(survivalobject), and then get the graph with ggsurvplot(surv_summary(survivalobject), risk.table = TRUE). Since the output from surv_summary(survivalobject) contains the n.risk column I expected to also get the risk table. No such luck.

My underlying objective is visualize a survival curve created by another method, as suggested in the ggsurvplot_df documentation. I want the at risk table also.

Actual behavior

When I use ggsurvplot(surv_summary(survivalobject), risk.table = TRUE) I do not get the at risk table. This is true even though surv_summary(survivalobject) does contain an n.risk column.

I dug through the documentation, and in fact the risk.table is not an option for ggsurvplot_df, so perhaps the missing at risk table should not surprise me. But I really want that at risk table. I suppose I could create a phony survival object, but that seems a real hack.

Steps to reproduce the problem

I tried this on the sample data sets from both the survminer and survival packages. Always the same result. No at risk table and no error message.

session_info()

# please paste here the result of
devtools::session_info()
>
> devtools::session_info()
- Session info ---------------------------------------------------------------
 setting  value                       
 version  R version 3.6.0 (2019-04-26)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       Rgui                        
 language (EN)                        
 collate  English_United States.1252  
 ctype    English_United States.1252  
 tz       America/Los_Angeles         
 date     2019-07-15                  

- Packages -------------------------------------------------------------------
 package     * version  date       lib source        
 assertthat    0.2.1    2019-03-21 [1] CRAN (R 3.6.0)
 backports     1.1.4    2019-04-10 [1] CRAN (R 3.6.0)
 broom         0.5.2    2019-04-07 [1] CRAN (R 3.6.0)
 callr         3.2.0    2019-03-15 [1] CRAN (R 3.6.0)
 cli           1.1.0    2019-03-19 [1] CRAN (R 3.6.0)
 cmprsk        2.2-8    2019-05-27 [1] CRAN (R 3.6.0)
 colorspace    1.4-1    2019-03-18 [1] CRAN (R 3.6.0)
 crayon        1.3.4    2017-09-16 [1] CRAN (R 3.6.0)
 data.table    1.12.2   2019-04-07 [1] CRAN (R 3.6.0)
 desc          1.2.0    2018-05-01 [1] CRAN (R 3.6.1)
 devtools    * 2.1.0    2019-07-06 [1] CRAN (R 3.6.1)
 digest        0.6.19   2019-05-20 [1] CRAN (R 3.6.0)
 dplyr         0.8.1    2019-05-14 [1] CRAN (R 3.6.0)
 fs            1.3.1    2019-05-06 [1] CRAN (R 3.6.0)
 generics      0.0.2    2018-11-29 [1] CRAN (R 3.6.0)
 ggplot2     * 3.2.0    2019-06-16 [1] CRAN (R 3.6.0)
 ggpubr      * 0.2      2018-11-15 [1] CRAN (R 3.6.0)
 glue          1.3.1    2019-03-12 [1] CRAN (R 3.6.0)
 gridExtra     2.3      2017-09-09 [1] CRAN (R 3.6.0)
 gtable        0.3.0    2019-03-25 [1] CRAN (R 3.6.0)
 km.ci         0.5-2    2009-08-30 [1] CRAN (R 3.6.0)
 KMsurv        0.1-5    2012-12-03 [1] CRAN (R 3.6.0)
 knitr         1.23     2019-05-18 [1] CRAN (R 3.6.0)
 labeling      0.3      2014-08-23 [1] CRAN (R 3.6.0)
 lattice       0.20-38  2018-11-04 [2] CRAN (R 3.6.0)
 lazyeval      0.2.2    2019-03-15 [1] CRAN (R 3.6.0)
 magrittr    * 1.5      2014-11-22 [1] CRAN (R 3.6.0)
 Matrix        1.2-17   2019-03-22 [2] CRAN (R 3.6.0)
 memoise       1.1.0    2017-04-21 [1] CRAN (R 3.6.1)
 munsell       0.5.0    2018-06-12 [1] CRAN (R 3.6.0)
 nlme          3.1-139  2019-04-09 [2] CRAN (R 3.6.0)
 pillar        1.4.1    2019-05-28 [1] CRAN (R 3.6.0)
 pkgbuild      1.0.3    2019-03-20 [1] CRAN (R 3.6.1)
 pkgconfig     2.0.2    2018-08-16 [1] CRAN (R 3.6.0)
 pkgload       1.0.2    2018-10-29 [1] CRAN (R 3.6.1)
 prettyunits   1.0.2    2015-07-13 [1] CRAN (R 3.6.0)
 processx      3.3.1    2019-05-08 [1] CRAN (R 3.6.0)
 ps            1.3.0    2018-12-21 [1] CRAN (R 3.6.0)
 purrr         0.3.2    2019-03-15 [1] CRAN (R 3.6.0)
 R6            2.4.0    2019-02-14 [1] CRAN (R 3.6.0)
 Rcpp          1.0.1    2019-03-17 [1] CRAN (R 3.6.0)
 remotes       2.1.0    2019-06-24 [1] CRAN (R 3.6.1)
 rlang         0.3.4    2019-04-07 [1] CRAN (R 3.6.0)
 rprojroot     1.3-2    2018-01-03 [1] CRAN (R 3.6.0)
 scales        1.0.0    2018-08-09 [1] CRAN (R 3.6.0)
 sessioninfo   1.1.1    2018-11-05 [1] CRAN (R 3.6.1)
 survival    * 2.44-1.1 2019-04-01 [2] CRAN (R 3.6.0)
 survminer   * 0.4.4    2019-05-21 [1] CRAN (R 3.6.0)
 survMisc      0.5.5    2018-07-05 [1] CRAN (R 3.6.0)
 testthat      2.1.1    2019-04-23 [1] CRAN (R 3.6.1)
 tibble        2.1.3    2019-06-06 [1] CRAN (R 3.6.0)
 tidyr         0.8.3    2019-03-01 [1] CRAN (R 3.6.0)
 tidyselect    0.2.5    2018-10-11 [1] CRAN (R 3.6.0)
 usethis     * 1.5.1    2019-07-04 [1] CRAN (R 3.6.1)
 withr         2.1.2    2018-03-15 [1] CRAN (R 3.6.0)
 xfun          0.7      2019-05-14 [1] CRAN (R 3.6.0)
 xtable        1.8-4    2019-04-21 [1] CRAN (R 3.6.0)
 zoo           1.8-6    2019-05-28 [1] CRAN (R 3.6.0)

wnilesanderson avatar Jul 15 '19 18:07 wnilesanderson

Did you ever find a solution to this? I'm having the same issue.

ApexHeel avatar Jun 06 '22 11:06 ApexHeel

I never did find a solution using the package. I just worked around it, and I have now moved on to other things.

Bill

Sent from my iPad

On Jun 6, 2022, at 4:45 AM, ApexHeel @.***> wrote:

 Did you ever find a solution to this? I'm having the same issue.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

wnilesanderson avatar Jun 06 '22 13:06 wnilesanderson