kassambara / survminer

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

gggcoxzph doesn't produce a plot when only 1 predictor variable #103

Closed ziegleml closed 7 years ago

ziegleml commented 7 years ago

Expected behavior

I am expecting that a plot will be produced for the single predictor variable in the model.

Actual behavior

Error in x$table["GLOBAL", 3] : subscript out of bounds

Steps to reproduce the problem

This is the example with the package - works fine (also works for 2 predictors)

fit <- coxph(Surv(futime, fustat) ~ age + ecog.ps + rx, data=ovarian) cox.zph.fit <- cox.zph(fit) ggcoxzph(cox.zph.fit)

This is the example but with only a single predictor - age

fit <- coxph(Surv(futime, fustat) ~ age, data=ovarian) cox.zph.fit <- cox.zph(fit) ggcoxzph(cox.zph.fit)

Error message is returned

Error in x$table["GLOBAL", 3] : subscript out of bounds

session_info()

# please paste here the result of
Session info -----------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   x86_64, mingw32             
 ui       RStudio (1.0.44)            
 language (EN)                        
 collate  English_United States.1252  
 tz       America/New_York            
 date     2017-01-06                  
kassambara commented 7 years ago

Thank you for reporting this issue. Bug fixed now!

MarcinKosinski commented 7 years ago

+! Thanks kassambara