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

Special characters cannot be used for levels names of a categorical variable #91

Closed
dnzmarcio opened this issue Dec 9, 2016 · 2 comments

Comments

@dnzmarcio
Copy link

dnzmarcio commented Dec 9, 2016

Expected behavior

Drawing survival curves for any categorical variable.

Actual behavior

If the categorical variable has levels with characters '>', '<=' then survival curves are not drawn.

Steps to reproduce the problem

library(survival)
library(survminer)
data(lung)

age.c <- ifelse(lung$age < 50, "<= 50", "> 50")
lung2 <- data.frame(lung, age.c)

fit <- survfit(Surv(time, status) ~ age.c, data = lung2)
ggsurvplot(fit)

session_info()

Session info ------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   i386, mingw32               
 ui       RStudio (1.0.44)            
 language (EN)                        
 collate  English_United States.1252  
 tz       America/Los_Angeles         
 date     2016-12-09                  

Packages ----------------------------------------------------------------------------------
 package    * version date       source        
 assertthat   0.1     2013-12-06 CRAN (R 3.3.2)
 colorspace   1.3-1   2016-11-18 CRAN (R 3.3.2)
 devtools   * 1.12.0  2016-06-24 CRAN (R 3.3.2)
 digest       0.6.10  2016-08-02 CRAN (R 3.3.2)
 ggplot2    * 2.2.0   2016-11-11 CRAN (R 3.3.2)
 gtable       0.2.0   2016-02-26 CRAN (R 3.3.2)
 lattice      0.20-34 2016-09-06 CRAN (R 3.3.2)
 lazyeval     0.2.0   2016-06-12 CRAN (R 3.3.2)
 magrittr     1.5     2014-11-22 CRAN (R 3.3.2)
 Matrix       1.2-7.1 2016-09-01 CRAN (R 3.3.2)
 memoise      1.0.0   2016-01-29 CRAN (R 3.3.2)
 munsell      0.4.3   2016-02-13 CRAN (R 3.3.2)
 plyr         1.8.4   2016-06-08 CRAN (R 3.3.2)
 Rcpp         0.12.8  2016-11-17 CRAN (R 3.3.2)
 scales       0.4.1   2016-11-09 CRAN (R 3.3.2)
 survival   * 2.40-1  2016-10-30 CRAN (R 3.3.2)
 survminer  * 0.2.3   2016-12-07 CRAN (R 3.3.2)
 tibble       1.2     2016-08-26 CRAN (R 3.3.2)
 withr        1.0.2   2016-06-20 CRAN (R 3.3.2)
@dnzmarcio dnzmarcio mentioned this issue Dec 9, 2016
kassambara added a commit that referenced this issue Dec 10, 2016
kassambara added a commit that referenced this issue Dec 10, 2016
@kassambara
Copy link
Owner

Hi @dnzmarcio,

To extract variable names used in survival::survfit(), the R code strsplit(strata, "=|,\\s+", perl=TRUE) was used in the surv_summary() function [survminer v0.2.3]. The splitting was done at any "=" symbol in the string, causing an error when special characters (=, <=, >=) are used for the levels of a categorical variable.

This has been now fixed by applying strsplit() only on the first instance of "=" symbol.

Thank you for pointing this out.

Best regards,
/A. Kassambara

kassambara added a commit that referenced this issue Dec 10, 2016
kassambara added a commit that referenced this issue Dec 10, 2016
@dnzmarcio
Copy link
Author

Thank you.

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

2 participants