簡體   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