Open ThomasGro opened 2 years ago
This has happened to me as well. Is there any solution?
Hi all, long time Kassambara package user, first time poster.
I have been having the same problem in 0.4.0 version. I just updated to 0.5.0 hoping it would fix itself but the p-value error persists. Trying to wrap up a thesis and manuscript and was going crazy until I found a fix. I actually noticed 2 different error codes dependent upon the facet variable class.
Using ThomasGro's original example:
fit=survfit( Surv(time.month, cnsr) ~ bm+status, data=data) ggsurvplot( fit, data, facet.by = "bm", pval = T)
If "bm" is a character then the error returns as "Error in Surv(time.month, cnsr) : object 'time.month' not found" If "bm" is a factor then I would get "Error in if (xi > xj) 1L else -1L : missing value where TRUE/FALSE needed"
These errors were the same if using the ggsurvplot_facet function.
How to Fix
Forcibly ensure your data is in data.frame format before plotting. This will hopefully work for you. It just worked for me. It doesn't matter if your facet variable is class character or factor either as long as you use as.data.frame().
data <- as.data.frame(data) fit=survfit( Surv(time.month, cnsr) ~ bm+status, data=data) ggsurvplot( fit, data, facet.by = "bm", pval = T)
I REALLY HOPE THIS HELPS EVERYONE CONTINUE TO USE SUCH A GREAT PACKAGE!
Hi bth117, indeed that works. Thank you for finding and providing this solution.
Hi @bth117 , thanks for your suggestion, it solved my problem as well!
Yes!! Worked for me too - amazing, thank you. This is otherwise a very helpful and well put-together package.
Expected behavior
P-value calculation per facet
Actual behavior
Error in Surv(time.month, cnsr) : object 'time.month' not found In addition: Warning message: In xtfrm.data.frame(x) : cannot xtfrm data frames
Without the pval parameter plots are generated.
Steps to reproduce the problem
a minimal data set:
session_info()
Matrix products: default BLAS/LAPACK: /usr/lib64/libopenblas_pthreads.so.0
locale: [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8
[6] LC_MESSAGES=C.UTF-8 LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices datasets utils methods base
other attached packages: [1] colorspace_2.0-3 scales_1.2.0 survminer_0.4.9 ggpubr_0.4.0 survival_3.3-1
[6] directlabels_2021.1.13 janitor_2.1.0 ProfilerAPI2_2.3.4 forcats_0.5.1 stringr_1.4.0
[11] dplyr_1.0.9 purrr_0.3.4 readr_2.1.2 tidyr_1.2.0 tibble_3.1.7
[16] ggplot2_3.3.6 tidyverse_1.3.1 plyr_1.8.7
loaded via a namespace (and not attached): [1] ggtext_0.1.1 fs_1.5.2 lubridate_1.8.0 bit64_4.0.5 httr_1.4.3 ggsci_2.9 tools_4.1.1
[8] backports_1.4.1 utf8_1.2.2 R6_2.5.1 DT_0.23 DBI_1.1.3 withr_2.5.0 RPresto_1.3.7
[15] tidyselect_1.1.2 gridExtra_2.3 bit_4.0.4 curl_4.3.2 compiler_4.1.1 cli_3.3.0 rvest_1.0.2
[22] xml2_1.3.3 labeling_0.4.2 survMisc_0.5.6 quadprog_1.5-8 digest_0.6.29 R.utils_2.12.0 ini_0.3.1
[29] pkgconfig_2.0.3 htmltools_0.5.2 dbplyr_2.2.1 fastmap_1.1.0 htmlwidgets_1.5.4 rlang_1.0.4 readxl_1.4.0
[36] rstudioapi_0.13 farver_2.1.1 generics_0.1.3 zoo_1.8-10 jsonlite_1.8.0 vroom_1.5.7 car_3.1-0
[43] R.oo_1.25.0 magrittr_2.0.3 Matrix_1.4-1 Rcpp_1.0.9 munsell_0.5.0 fansi_1.0.3 abind_1.4-5
[50] lifecycle_1.0.1 R.methodsS3_1.8.2 stringi_1.7.8 snakecase_0.11.0 carData_3.0-5 grid_4.1.1 blob_1.2.3
[57] parallel_4.1.1 crayon_1.5.1 lattice_0.20-45 haven_2.5.0 splines_4.1.1 gridtext_0.1.4 hms_1.1.1
[64] knitr_1.39 pillar_1.7.0 markdown_1.1 ggsignif_0.6.3 reprex_2.0.1 glue_1.6.2 data.table_1.14.2 [71] renv_0.15.4 modelr_0.1.8 vctrs_0.4.1 tzdb_0.3.0 cellranger_1.1.0 gtable_0.3.0 km.ci_0.5-6
[78] assertthat_0.2.1 xfun_0.31 xtable_1.8-4 broom_1.0.0 rstatix_0.7.0 KMsurv_0.1-5 ellipsis_0.3.2