kassambara / survminer

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

Errore: object of type 'symbol' is not subsettable #466

Closed Rackdos closed 4 years ago

Rackdos commented 4 years ago

Expected behavior

survival function graph

Actual behavior

Errore: object of type 'symbol' is not subsettable

Steps to reproduce the problem

library(survival) library(survminer) data("lung") res.cox <- coxph(Surv(time, status) ~ age + sex + ph.ecog, data = lung) summary(res.cox) ggsurvplot(survfit(res.cox, data = lung), palette = "#2E9FDF", ggtheme = theme_minimal(), data = lung)

session_info()

R version 4.0.0 (2020-04-24) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Catalina 10.15.3

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale: [1] it_IT.UTF-8/it_IT.UTF-8/it_IT.UTF-8/C/it_IT.UTF-8/it_IT.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] survminer_0.4.6 ggpubr_0.2.5 magrittr_1.5 ggplot2_3.3.0 survival_3.1-12

loaded via a namespace (and not attached): [1] Rcpp_1.0.4.6 pillar_1.4.3 compiler_4.0.0 tools_4.0.0 lifecycle_0.2.0 tibble_3.0.1 gtable_0.3.0 nlme_3.1-147
[9] lattice_0.20-41 pkgconfig_2.0.3 rlang_0.4.5 Matrix_1.2-18 rstudioapi_0.11 xfun_0.13 gridExtra_2.3 withr_2.2.0
[17] dplyr_0.8.5 knitr_1.28 generics_0.0.2 vctrs_0.2.4 survMisc_0.5.5 grid_4.0.0 tidyselect_1.0.0 data.table_1.12.8 [25] glue_1.4.0 R6_2.4.1 KMsurv_0.1-5 km.ci_0.5-2 purrr_0.3.4 tidyr_1.0.2 scales_1.1.0 backports_1.1.6
[33] ellipsis_0.3.0 splines_4.0.0 assertthat_0.2.1 xtable_1.8-4 colorspace_1.4-1 ggsignif_0.6.0 labeling_0.3 munsell_0.5.0
[41] broom_0.5.6 crayon_1.3.4 zoo_1.8-7

# please paste here the result of
devtools::session_info()
Rackdos commented 4 years ago

I found these commands in a cox regression tutorial. To be honest I added "data=lung" in both "survfit" and "ggsurvplot" functions or the error was: "Error in .get_data(fit, data = data, complain = FALSE) : The data argument should be provided either to ggsurvfit or survfit.". I tried to add "data=lung" in only one of them too, but the result is always "Errore: object of type 'symbol' is not subsettable". Hope to have been clear.

manuelmateus16 commented 4 years ago

I am also experiencing the same error "Error: object of type 'symbol' is not subsettable".

library(survminer)
library(survival)

res.cox <- coxph(Surv(tstart, tstop, Falecido) ~ Idade_no_diagnostico + Nr_cirurgias_acumuladas + Severidade, data=analise_survival_extended_Cox_PH)
fit <- survfit(res.cox, data=analise_survival_extended_Cox_PH)
ggsurvplot(fit, data=analise_survival_extended_Cox_PH)

Session info R version 3.6.1 (2019-07-05) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Catalina 10.15.4 survminer_0.4.6 survival_3.1-8

I believe this is the same issue as #441

kassambara commented 4 years ago

duplicate of #441, fixed now, thanks!