Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorized input to element_text() is not officially supported #455

Closed
rfbrondum opened this issue Mar 11, 2020 · 10 comments
Closed

Vectorized input to element_text() is not officially supported #455

rfbrondum opened this issue Mar 11, 2020 · 10 comments

Comments

@rfbrondum
Copy link

Expected behavior

No warning. Plots seem to work fine, but it would be nice not to get an error.

Actual behavior

When plotting a risk table with for more than one factor level I get a warning saying: "Vectorized input to element_text() is not officially supported. Results may be unexpected or may change in future versions of ggplot2. "

Steps to reproduce the problem

library(survminer)
library(survival)

data("cancer")

ggsurvplot(survfit(Surv(cancer$time, cancer$status)~1),
           data = cancer,
           risk.table = T)

ggsurvplot(survfit(Surv(cancer$time, cancer$status)~cancer$ph.ecog),
           data = cancer,
           risk.table = T)

session_info()

- Session info ----------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.6.2 (2019-12-12)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  Danish_Denmark.1252         
 ctype    Danish_Denmark.1252         
 tz       Europe/Paris                
 date     2020-03-11                  

- Packages --------------------------------------------------------------------------------------------------------------------
 ! package     * version date       lib source        
   assertthat    0.2.1   2019-03-21 [1] CRAN (R 3.6.0)
   backports     1.1.5   2019-10-02 [1] CRAN (R 3.6.1)
   broom         0.5.4   2020-01-27 [1] CRAN (R 3.6.2)
   callr         3.4.1   2020-01-24 [1] CRAN (R 3.6.2)
   cli           2.0.1   2020-01-08 [1] CRAN (R 3.6.2)
   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.8  2019-12-09 [1] CRAN (R 3.6.2)
   desc          1.2.0   2018-05-01 [1] CRAN (R 3.6.0)
   devtools      2.2.1   2019-09-24 [1] CRAN (R 3.6.2)
   digest        0.6.23  2019-11-23 [1] CRAN (R 3.6.2)
   dplyr         0.8.4   2020-01-31 [1] CRAN (R 3.6.2)
   ellipsis      0.3.0   2019-09-20 [1] CRAN (R 3.6.2)
   fansi         0.4.1   2020-01-08 [1] CRAN (R 3.6.2)
   farver        2.0.3   2020-01-16 [1] CRAN (R 3.6.2)
   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.3.0   2020-03-05 [1] CRAN (R 3.6.2)
   ggpubr      * 0.2.4   2019-11-14 [1] CRAN (R 3.6.2)
   ggsignif      0.6.0   2019-08-08 [1] CRAN (R 3.6.1)
   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.27    2020-01-16 [1] CRAN (R 3.6.2)
   labeling      0.3     2014-08-23 [1] CRAN (R 3.6.0)
 D lattice       0.20-38 2018-11-04 [1] CRAN (R 3.6.2)
   lifecycle     0.1.0   2019-08-01 [1] CRAN (R 3.6.2)
   magrittr    * 1.5     2014-11-22 [1] CRAN (R 3.6.0)
 D Matrix        1.2-18  2019-11-27 [1] CRAN (R 3.6.2)
   memoise       1.1.0   2017-04-21 [1] CRAN (R 3.6.0)
   munsell       0.5.0   2018-06-12 [1] CRAN (R 3.6.0)
   nlme          3.1-143 2019-12-10 [1] CRAN (R 3.6.2)
   pillar        1.4.3   2019-12-20 [1] CRAN (R 3.6.2)
   pkgbuild      1.0.6   2019-10-09 [1] CRAN (R 3.6.2)
   pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 3.6.2)
   pkgload       1.0.2   2018-10-29 [1] CRAN (R 3.6.0)
   prettyunits   1.1.1   2020-01-24 [1] CRAN (R 3.6.2)
   processx      3.4.1   2019-07-18 [1] CRAN (R 3.6.1)
   ps            1.3.0   2018-12-21 [1] CRAN (R 3.6.0)
   purrr         0.3.3   2019-10-18 [1] CRAN (R 3.6.2)
   R6            2.4.1   2019-11-12 [1] CRAN (R 3.6.2)
   Rcpp          1.0.3   2019-11-08 [1] CRAN (R 3.6.2)
   remotes       2.1.0   2019-06-24 [1] CRAN (R 3.6.1)
   rlang         0.4.4   2020-01-28 [1] CRAN (R 3.6.2)
   rprojroot     1.3-2   2018-01-03 [1] CRAN (R 3.6.0)
   rstudioapi    0.10    2019-03-19 [1] CRAN (R 3.6.0)
   scales        1.1.0   2019-11-18 [1] CRAN (R 3.6.2)
   sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.6.0)
 D survival    * 3.1-8   2019-12-03 [1] CRAN (R 3.6.2)
   survminer   * 0.4.6   2019-09-03 [1] CRAN (R 3.6.3)
   survMisc      0.5.5   2018-07-05 [1] CRAN (R 3.6.0)
   testthat      2.3.1   2019-12-01 [1] CRAN (R 3.6.2)
   tibble        2.1.3   2019-06-06 [1] CRAN (R 3.6.0)
   tidyr         1.0.2   2020-01-24 [1] CRAN (R 3.6.2)
   tidyselect    1.0.0   2020-01-27 [1] CRAN (R 3.6.2)
   usethis       1.5.1   2019-07-04 [1] CRAN (R 3.6.1)
   vctrs         0.2.2   2020-01-24 [1] CRAN (R 3.6.2)
   withr         2.1.2   2018-03-15 [1] CRAN (R 3.6.0)
   xfun          0.12    2020-01-13 [1] CRAN (R 3.6.2)
   xtable        1.8-4   2019-04-21 [1] CRAN (R 3.6.0)
   zoo           1.8-7   2020-01-10 [1] CRAN (R 3.6.2)

[1] C:/Users/xxxx/Documents/R/R-3.6.2/library

 D -- DLL MD5 mismatch, broken installation.
@mc123at
Copy link

mc123at commented Mar 17, 2020

Yes, I have the same warning.

Do you have the same problem as mine?

The style of the "Number of censoring" is ok?

My question here: #456
Thanks.

@rfbrondum
Copy link
Author

No, I get vertical bars for number of censoring, so that does not seem to be an issue.

@tiger-liang
Copy link

I have the same warning.

@billudada78
Copy link

I think the issue may be more than an annoying warning. Is ph.ecog a factor variable in your dataset? Try checking whether your risk table has the correct groups listed against each row in the risk table. See my recent post for an example of this error:

#464

@rfbrondum
Copy link
Author

Risk table looks correct. ph.ecog is coded as numeric, although it strictly speaking is a categorical variable, but forcing it as a factor does not change anything.

@billudada78
Copy link

@rfbrondum Thanks for confirming that your factored version is not impacted by whatever issue is present in my case!

@ipstone
Copy link

ipstone commented Nov 20, 2020

report the same issue as well

@motocci
Copy link

motocci commented Dec 7, 2020

I report the same issue as well.

@kassambara
Copy link
Owner

The warning concerns these lines of codes

survminer/R/ggsurvtable.R

Lines 317 to 323 in acff36f

# Color table tick labels by strata
if(is.logical(y.text.col) & y.text.col[1] == TRUE){
cols <- .extract_ggplot_colors(p, grp.levels = legend.labs)
p <- p + theme(axis.text.y = element_text(colour = rev(cols)))
}
else if(is.character(y.text.col))
p <- p + theme(axis.text.y = element_text(colour = rev(y.text.col)))
. element_text() now issues a warning when vectorized arguments are provided, as in colour = c("red", "green", "blue"). Such use is discouraged and not officially supported. I'm looking for a best solution to replace these lines.

@kassambara
Copy link
Owner

fixed now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants