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

[BUG] Error when `ggsurvplot` is used inside function. #125

Closed
zzawadz opened this issue Jan 26, 2017 · 6 comments
Closed

[BUG] Error when `ggsurvplot` is used inside function. #125

zzawadz opened this issue Jan 26, 2017 · 6 comments

Comments

@zzawadz
Copy link
Contributor

@zzawadz zzawadz commented Jan 26, 2017

Expected behavior

ggsurvplot should be able to be used inside other functions.

Actual behavior

Error is thrown when ggsurvplot is used inside function.

Steps to reproduce the problem

library(survminer)
require("survival")

tmp <- function(dt) 
{
  lung2 <- dt
  fit<- survfit(Surv(time, status) ~ sex, data = lung2)
  ggsurvplot(fit)
}

tmp(lung) #error!

session_info()

Session info ----------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.1 (2016-06-21)
 system   x86_64, linux-gnu           
 ui       RStudio (1.0.44)            
 language (EN)                        
 collate  pl_PL.UTF-8                 
 tz       Europe/Warsaw               
 date     2017-01-26                  

Packages --------------------------------------------------------------------------------------
 package    * version   date       source                               
 assertthat   0.1       2013-12-06 CRAN (R 3.3.1)                       
 broom        0.4.1     2016-06-24 cran (@0.4.1)                        
 colorspace   1.3-2     2016-12-14 CRAN (R 3.3.1)                       
 DBI          0.5-1     2016-09-10 CRAN (R 3.3.1)                       
 devtools     1.12.0    2016-06-24 CRAN (R 3.3.1)                       
 digest       0.6.11    2017-01-03 cran (@0.6.11)                       
 dplyr        0.5.0     2016-06-24 CRAN (R 3.3.1)                       
 foreign      0.8-67    2016-09-13 CRAN (R 3.3.1)                       
 ggplot2    * 2.2.1     2016-12-30 cran (@2.2.1)                        
 gtable       0.2.0     2016-02-26 CRAN (R 3.3.1)                       
 lattice      0.20-34   2016-09-06 CRAN (R 3.3.1)                       
 lazyeval     0.2.0     2016-06-12 CRAN (R 3.3.1)                       
 magrittr     1.5       2014-11-22 CRAN (R 3.3.1)                       
 Matrix       1.2-7.1   2016-09-01 CRAN (R 3.3.1)                       
 memoise      1.0.0     2016-01-29 CRAN (R 3.3.1)                       
 mnormt       1.5-5     2016-10-15 CRAN (R 3.3.1)                       
 munsell      0.4.3     2016-02-13 CRAN (R 3.3.1)                       
 nlme         3.1-128   2016-05-10 CRAN (R 3.3.1)                       
 plyr         1.8.4     2016-06-08 CRAN (R 3.3.1)                       
 psych        1.6.12    2017-01-08 CRAN (R 3.3.1)                       
 R6           2.2.0     2016-10-05 CRAN (R 3.3.1)                       
 Rcpp         0.12.9    2017-01-16 Github (RcppCore/Rcpp@f57467b)       
 reshape2     1.4.2     2016-10-22 CRAN (R 3.3.1)                       
 scales       0.4.1     2016-11-09 CRAN (R 3.3.1)                       
 stringi      1.1.2     2016-10-01 CRAN (R 3.3.1)                       
 stringr      1.1.0     2016-08-19 CRAN (R 3.3.1)                       
 survival   * 2.40-1    2016-10-30 CRAN (R 3.3.1)                       
 survminer  * 0.2.4.999 2017-01-26 Github (kassambara/survminer@0f036ed)
 tibble       1.2       2016-08-26 CRAN (R 3.3.1)                       
 tidyr        0.6.1     2017-01-10 cran (@0.6.1)                        
 withr        1.0.2     2016-06-20 CRAN (R 3.3.1) 
zzawadz added a commit to zzawadz/survminer that referenced this issue Jan 26, 2017
@zzawadz
Copy link
Contributor Author

@zzawadz zzawadz commented Jan 26, 2017

One possible (and very simple solution) is to add parameter data which should be used only inside other functions. I will think about better solutions, but for now nothing comes to my mind;)

@kassambara
Copy link
Owner

@kassambara kassambara commented Jan 26, 2017

Using the function do.call()should fix this issue.

For example:

library(survminer)
require("survival")

tmp <- function(dt) 
{
  lung2 <- dt
  fit <- do.call(survfit,
                 list(formula = Surv(time, status) ~ sex, data = lung2))
  ggsurvplot(fit)
}

tmp(lung)
@MarcinKosinski
Copy link
Contributor

@MarcinKosinski MarcinKosinski commented Jan 27, 2017

I think this is related to survift itselft, and not to the ggsurvplot.
@zzawadz this solution was also mentioned here #9 and RTCGA/RTCGA#48

@MarcinKosinski
Copy link
Contributor

@MarcinKosinski MarcinKosinski commented Jan 27, 2017

I think we might create a FAQ because issues became repeatable :)

@kassambara
Copy link
Owner

@kassambara kassambara commented Jan 28, 2017

Absolutely for the FAQ!!

@ghowoo
Copy link

@ghowoo ghowoo commented Sep 25, 2020

think this is related to survift itselft, and not to the ggsurvplot.
@zzawadz this solution was also mentioned here #9 and RTCGA/RTCGA#48

I agree. The survfit function's formula construction seems not quite conventional.

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.