繁体   English   中英

在 R: survminer::ggsurvplot with fun = "cloglog" 返回警告信息和空图

[英]In R: survminer::ggsurvplot with fun = "cloglog" returns warning message and empty plot

请考虑以下事项:

随着survminer打包对象的生存与包创建我们可以得出“对数”情节survival 这是包开发人员@kassambara 不久前在这里介绍的

直到最近一切正常,但随着更新到更新的 R 和 RStudio 版本,我收到一条警告消息和一个空图。

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) ~ sex, data = lung)
ggsurvplot(fit, data = lung, fun = "cloglog")
#> Warning: Transformation introduced infinite values in continuous x-axis

#> Warning: Transformation introduced infinite values in continuous x-axis

print(sessionInfo(), locale = FALSE)
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 16299)
#> 
#> Matrix products: default
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] survminer_0.4.6   ggpubr_0.2.3      magrittr_1.5      ggplot2_3.2.1    
#> [5] survival_2.44-1.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.1        pillar_1.4.2      compiler_3.6.1   
#>  [4] highr_0.8         tools_3.6.1       digest_0.6.20    
#>  [7] nlme_3.1-140      evaluate_0.14     tibble_2.1.3     
#> [10] gtable_0.3.0      lattice_0.20-38   pkgconfig_2.0.2  
#> [13] rlang_0.4.0       Matrix_1.2-17     yaml_2.2.0       
#> [16] xfun_0.8          gridExtra_2.3     withr_2.1.2      
#> [19] stringr_1.4.0     dplyr_0.8.3       knitr_1.23       
#> [22] survMisc_0.5.5    generics_0.0.2    grid_3.6.1       
#> [25] tidyselect_0.2.5  data.table_1.12.2 glue_1.3.1       
#> [28] KMsurv_0.1-5      R6_2.4.0          km.ci_0.5-2      
#> [31] rmarkdown_1.15    tidyr_0.8.3       purrr_0.3.2      
#> [34] backports_1.1.4   scales_1.0.0      htmltools_0.3.6  
#> [37] splines_3.6.1     assertthat_0.2.1  xtable_1.8-4     
#> [40] colorspace_1.4-1  ggsignif_0.6.0    labeling_0.3     
#> [43] stringi_1.4.3     lazyeval_0.2.2    munsell_0.5.0    
#> [46] broom_0.5.2       crayon_1.3.4      zoo_1.8-6

reprex 包(v0.3.0) 于 2019 年 9 月 4 日创建

我的 RStudio 版本是 1.2.1335


在此处与软件包开发人员标记了此问题,但他似乎无法重现相同的错误(请参见此处)。

对我来说,错误发生在 Windows 和 Mac 上。 与此同时,我使用update.packages(checkBuilt = TRUE, ask = FALSE)更新了两个系统上的所有包,但没有任何成功。 奇怪的是,我的一位同事使用旧版本的 R 和 RStudio 可以很好地绘制绘图,就像包开发人员一样。

我做错了什么,我能做什么?

谢谢!


更新
回滚多个版本的 R 和包,我发现了一种有效的版本(R 和包)组合。 我不完全理解这是怎么回事,但似乎一个或多个包与 R 版本的交互效果不佳。 我在这里附上工作组合的会话信息,并将其留给策划者进一步探索(如果有任何兴趣)。

require("survival")
#> Loading required package: survival
require("survminer")
#> Loading required package: survminer
#> Warning: package 'survminer' was built under R version 3.5.3
#> Loading required package: ggplot2
#> Warning: package 'ggplot2' was built under R version 3.5.3
#> Loading required package: ggpubr
#> Warning: package 'ggpubr' was built under R version 3.5.3
#> Loading required package: magrittr
fit<- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data = lung, fun = "cloglog")

print(sessionInfo(), locale = FALSE)
#> R version 3.5.1 (2018-07-02)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS  10.14.6
#> 
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] survminer_0.4.2 ggpubr_0.2.3    magrittr_1.5    ggplot2_3.1.1  
#> [5] survival_2.42-3
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.2        compiler_3.5.1    pillar_1.4.2     
#>  [4] plyr_1.8.4        highr_0.8         tools_3.5.1      
#>  [7] digest_0.6.20     nlme_3.1-137      evaluate_0.14    
#> [10] tibble_2.1.3      gtable_0.3.0      lattice_0.20-35  
#> [13] pkgconfig_2.0.2   rlang_0.4.0       Matrix_1.2-14    
#> [16] cmprsk_2.2-7.1    yaml_2.2.0        xfun_0.9         
#> [19] gridExtra_2.3     withr_2.1.2       stringr_1.4.0    
#> [22] dplyr_0.8.3       knitr_1.24        survMisc_0.5.5   
#> [25] generics_0.0.2    grid_3.5.1        tidyselect_0.2.5 
#> [28] data.table_1.12.2 glue_1.3.1        KMsurv_0.1-5     
#> [31] R6_2.4.0          km.ci_0.5-2       rmarkdown_1.15   
#> [34] tidyr_0.8.3       purrr_0.3.2       backports_1.1.4  
#> [37] scales_1.0.0      htmltools_0.3.6   splines_3.5.1    
#> [40] assertthat_0.2.1  xtable_1.8-4      colorspace_1.4-1 
#> [43] ggsignif_0.6.0    labeling_0.3      stringi_1.4.3    
#> [46] lazyeval_0.2.2    munsell_0.5.0     broom_0.5.2      
#> [49] crayon_1.3.4      zoo_1.8-6

reprex 包(v0.3.0) 于 2019 年 9 月 5 日创建


可能的解决方法
@Robbe 的答案是一种可能的解决方法! 不过,我很犹豫是否将其标记为正确答案。 对此的任何建议也将受到欢迎。

我遇到了和你一样的错误,但你可以通过设置 xlim 在 x 轴上省略 0 来使它工作:

fit <- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data = lung, fun = "cloglog", xlim = c(1, 1000))

这是因为 x 轴是对数转换的,而 log(0) 是负无穷大,这会导致错误。

ggsurvplot 似乎不会自动执行此操作,而 plot 例如会:

fit<- survfit(Surv(time, status) ~ sex, data = lung)
plot(fit, data = lung, fun = "cloglog")

带有警告信息:

1: In xy.coords(x, y, xlabel, ylabel, log) :
  1 x value <= 0 omitted from logarithmic plot

这是我认为应该做的:

#identify the proper destination for the issue
 maintainer("survminer")
[1] "Alboukadel Kassambara <alboukadel.kassambara@gmail.com>"

撰写电子邮件并发送:

Subject = " Blank plot with "cloglog" option to ggsurvplot"

Body = c("Please see the recent StackOverflow dialog on this issue.",
"https://stackoverflow.com/questions/57791504/in-r-survminerggsurvplot-with-fun-cloglog-returns-warning-message-and-emp/57793157#57793157",
"I suggest error trapping for the possibility of a zero value on the time axis.",
"Sincerely;")

我确实发送了它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM