kassambara / survminer

Survival Analysis and Visualization
https://rpkgs.datanovia.com/survminer/
491 stars 160 forks source link

ggsurvplot returns an error if ncensor.plot = TRUE for model without strata #298

Open sbihorel opened 6 years ago

sbihorel commented 6 years ago

Expected behavior

Display of number of censoring plot when the survfit model has no strata.

Actual behavior

An error is returned.

Steps to reproduce the problem

require("survival")
#> Loading required package: survival
require('survminer')
#> Loading required package: survminer
#> Loading required package: ggplot2
#> Loading required package: ggpubr
#> Loading required package: magrittr
fit <- survfit(Surv(time, status) ~ 1, data = lung)
ggsurvplot(fit, data = lung, ncensor.plot = TRUE)
#> Error in grDevices::col2rgb(colour, TRUE): invalid color name 'strata'

session_info()

R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.1

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] survminer_0.4.2      ggpubr_0.1.6         magrittr_1.5         survival_2.41-3      rclipboard_0.1       markdown_0.8        
 [7] GGally_1.3.2         ggplot2_2.2.1        rhandsontable_0.3.4  DT_0.2               shinyjs_0.9.1        shinydashboard_0.6.1
[13] shiny_1.0.3         

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.11        lattice_0.20-35     tidyr_0.8.0         zoo_1.8-1           rprojroot_1.2       assertthat_0.2.0   
 [7] digest_0.6.12       psych_1.7.8         mime_0.5            R6_2.2.2            plyr_1.8.4          backports_1.1.1    
[13] reprex_0.1.2        evaluate_0.10.1     pillar_1.2.1        rlang_0.2.0         lazyeval_0.2.0      rstudioapi_0.7     
[19] data.table_1.10.4-3 miniUI_0.1.1        callr_2.0.2         whisker_0.3-2       Matrix_1.2-11       rmarkdown_1.7      
[25] labeling_0.3        splines_3.4.3       stringr_1.2.0       foreign_0.8-69      htmlwidgets_0.9     munsell_0.4.3      
[31] broom_0.4.3         compiler_3.4.3      httpuv_1.3.5        pkgconfig_2.0.1     mnormt_1.5-5        htmltools_0.3.6    
[37] tibble_1.4.2        gridExtra_2.2.1     km.ci_0.5-2         reshape_0.8.7       crayon_1.3.4        dplyr_0.7.4        
[43] grid_3.4.3          nlme_3.1-131        jsonlite_1.5        xtable_1.8-2        gtable_0.2.0        KMsurv_0.1-5       
[49] scales_0.4.1        debugme_1.1.0       stringi_1.1.5       reshape2_1.4.2      bindrcpp_0.2        survMisc_0.5.4     
[55] RColorBrewer_1.1-2  tools_3.4.3         cmprsk_2.2-7        glue_1.2.0          purrr_0.2.4         rsconnect_0.8.8    
[61] parallel_3.4.3      yaml_2.1.14         colorspace_1.3-2    knitr_1.17          bindr_0.1      
filipe-cogo commented 5 years ago

Hi @sbihorel, could you kindly report whether did you resolve this issue? I'm facing exactly the same problem. Thanks!

alexyfyf commented 5 years ago

Same problem here.

ghost commented 4 years ago

I'm facing exactly the same problem. Is there any workaround for that?

creativedoctor commented 4 years ago

Same here. Any suggestions?

ksm113 commented 4 years ago

Same here.

Javier-Amaya-Nieto commented 3 years ago

I belive it has to be with the idea that you only have one strata. Because when I added two strata to the curves, the chunk of code of ncensor.plto worked without problems.

bdawkins99 commented 3 years ago

I had the same issue. The problem went away when I assigned a value to the 'color' parameter. There is the following warning message though.

Warning message: Now, to change color palette, use the argument palette= '#E7B800' instead of color = '#E7B800'