Closed edvbb closed 4 years ago
I have the same problem running an old script that used to work. I think it has something to do with the introduction of surv_fit. Now I use an old method for plotting the reference patients I want:
fit1 <- survfit(cox_model, newdata = newdata, data = df)
plot( fit1, main = "Title", xlab = "Months", ylab = "Survival probability", col = c("#5DC863FF", "#21908CFF","#3B528BFF", "#440154FF")
Now, you need to specify the argument data
in ggsurvplot(). The data should be same as the one used to compute survfit()
. The following example works on my computer:
library("survival")
# Fit cox ph
#%%%%%%%%%%%%%
res.cox <- coxph(Surv(time, status) ~ age + sex + wt.loss, data = lung)
res.cox
# Survival curves by sex after adjusting by age and wt.loss
#%%%%%%%%%%%%%%%%%%%%%%%%
# we construct a new data frame with two rows,
# one for each value of sex; the other covariates are fixed to their average values
# Create the new data
new_df <- with(lung,
data.frame(sex = c(1, 2),
age = rep(mean(age, na.rm = TRUE), 2),
wt.loss = rep(mean(wt.loss, na.rm = TRUE), 2)
)
)
new_df
# Survival curves with new data
#%%%%%%%%%%%%%%%%%%%%%%%%%%%
library(survminer)
fit <- survfit(res.cox, newdata = new_df)
ggsurvplot(fit, data = new_df, conf.int = TRUE, palette = "Dark2",
censor = FALSE, surv.median.line = "hv")
Unfortunately, when I your example this also gives:
Error: object of type 'symbol' is not subsettable
I run: Rstudio - Version 1.2.1578 R - Version 3.6.1 (2019-07-05) -- "Action of the Toes" Survival - Version 3.1.8 Survminer - Version 0.4.6
I can not re-Install the latest dev version
devtools::install_github("kassambara/survminer", build_vignettes = FALSE)
and get the error after
ggsurvplot(fit, data = new_df, conf.int = TRUE, palette = "Dark2",
censor = FALSE, surv.median.line = "hv")
Now, you need to specify the argument
data
in ggsurvplot(). The data should be same as the one used to computesurvfit()
. The following example works on my computer:library("survival") # Fit cox ph #%%%%%%%%%%%%% res.cox <- coxph(Surv(time, status) ~ age + sex + wt.loss, data = lung) res.cox # Survival curves by sex after adjusting by age and wt.loss #%%%%%%%%%%%%%%%%%%%%%%%% # we construct a new data frame with two rows, # one for each value of sex; the other covariates are fixed to their average values # Create the new data new_df <- with(lung, data.frame(sex = c(1, 2), age = rep(mean(age, na.rm = TRUE), 2), wt.loss = rep(mean(wt.loss, na.rm = TRUE), 2) ) ) new_df # Survival curves with new data #%%%%%%%%%%%%%%%%%%%%%%%%%%% library(survminer) fit <- survfit(res.cox, newdata = new_df) ggsurvplot(fit, data = new_df, conf.int = TRUE, palette = "Dark2", censor = FALSE, surv.median.line = "hv")
I seem to have a similar problem with the new updates as well. The test code provided above also doesn't work for me. I got a similar error message as @MvZeijl1986 Session Info: Platform: x86_64-conda_cos6-linux-gnu (64-bit) Running under: Ubuntu 16.04.6 LTS R version 3.6.1 (2019-07-05) survival_3.1-8 survminer_0.4.6
I get the same error "Error: object of type 'symbol' is not subsettable" using the following code.
However, if I substitute the function surv_fit() for survfit(), no error occurs, but the plot is of all strata combined, instead of by sex. How can I separate these out by sex when using surv_fit?
library("survival")
res.cox <- coxph(Surv(time, status) ~ age + sex + wt.loss, data = lung)
new_df <- with(lung,
data.frame(sex = c(1, 2),
age = rep(mean(age, na.rm = TRUE), 2),
wt.loss = rep(mean(wt.loss, na.rm = TRUE), 2)
)
)
library(survminer)
fit <- survfit(res.cox, newdata = new_df, data = lung)
ggsurvplot(fit, conf.int = TRUE, palette = "Dark2",
censor = FALSE, surv.median.line = "hv")
Ubuntu 18.04.4 LTS (Bionic Beaver) R version 3.6.2 (2019-12-12) survminer_0.4.6.999 survival_3.1-8
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
Has anyone found a solution to overcome this error?
Thank you.
Hi! I have the same problem.. Has anyone managed to solve it?
Now i do it with ggplot2
ALL CODE
library("survival")
res.cox <- coxph(Surv(time, status) ~ age + sex + wt.loss, data = lung)
res.cox
# Survival curves by sex after adjusting by age and wt.loss
#%%%%%%%%%%%%%%%%%%%%%%%%
# we construct a new data frame with two rows,
# one for each value of sex; the other covariates are fixed to their average values
# Create the new data
sex_df <- with(lung,
data.frame(sex = c(1, 2),
age = rep(mean(age, na.rm = TRUE), 2),
wt.loss = rep(mean(wt.loss, na.rm = TRUE), 2)
)
)
sex_df
# Survival curves
library("ggplot2")
fit <- survfit(res.cox, newdata = sex_df)
dat = data.frame(surv = fit$surv,lower= fit$lower, upper = fit$upper,time= fit$time)
library(reshape2)
data = melt(dat, id="time")
library(tidyr)
data_wide <- data %>%
separate(col = variable, into = c("type", "sex"), sep = "\\.") %>%
spread(key = type, value = value)
g <- ggplot(data = data_wide) +
geom_line(aes(x = time, y = surv, group = sex, colour = sex),
size = 3.5,
linetype = 1) +
geom_ribbon(aes(x = time, ymin = lower, ymax = upper, group = sex, fill = sex),
alpha = 0.5) +
scale_colour_manual(values = c("#E7B800", "#2E9FDF", 'red')) +
scale_fill_manual(values = c("#E7B800", "#2E9FDF", 'red')) +
scale_x_continuous(limits = c(0, 840),
breaks = seq(0, 840, 120)) +
theme(legend.position = "top",
axis.text = element_text(size = 20),
axis.title = element_text(size = 20),
legend.text = element_text(size = 40),
legend.key.size = unit(3, "line"),
legend.title = element_blank()) +
ylab("Surv prob") +
geom_segment(aes(x = 0, y = 0.5, xend = max(q1$`50`), yend =0.5), color="grey50",
linetype="dashed", size=1.5)
q1 = as.data.frame(quantile(fit, conf.int = F))
for (i in 1:length(q1$`50`)) {
g = g + geom_segment(x = q1$`50`[i], y = 0, xend = q1$`50`[i], yend = 0.5,
color="grey50", linetype="dashed", size=1.5)
}
g
This issue is due to a recent change in the survival package. In older versions of the survival package, the function survfit(res.cox)
returns an object of class survfit.cox
. The class has been changed to survfitcox in the current survival package version.
Will be fixed in few minutes, thanks
fixed in the latest dev version now (devtools::install_github("kassambara/survminer", build_vignettes = FALSE)
), thanks.
Please let me know if it works for you so that we can close this issue.
library("survival")
# Fit cox ph
#%%%%%%%%%%%%%
res.cox <- coxph(Surv(time, status) ~ age + sex + wt.loss, data = lung)
res.cox
#> Call:
#> coxph(formula = Surv(time, status) ~ age + sex + wt.loss, data = lung)
#>
#> coef exp(coef) se(coef) z p
#> age 0.0200882 1.0202913 0.0096644 2.079 0.0377
#> sex -0.5210319 0.5939074 0.1743541 -2.988 0.0028
#> wt.loss 0.0007596 1.0007599 0.0061934 0.123 0.9024
#>
#> Likelihood ratio test=14.67 on 3 df, p=0.002122
#> n= 214, number of events= 152
#> (14 observations deleted due to missingness)
# Survival curves by sex after adjusting by age and wt.loss
#%%%%%%%%%%%%%%%%%%%%%%%%
# we construct a new data frame with two rows,
# one for each value of sex; the other covariates are fixed to their average values
# Create the new data
new_df <- with(lung,
data.frame(sex = c(1, 2),
age = rep(mean(age, na.rm = TRUE), 2),
wt.loss = rep(mean(wt.loss, na.rm = TRUE), 2)
)
)
new_df
#> sex age wt.loss
#> 1 1 62.44737 9.831776
#> 2 2 62.44737 9.831776
# Survival curves with new data
#%%%%%%%%%%%%%%%%%%%%%%%%%%%
library(survminer)
#> Le chargement a nécessité le package : ggplot2
#> Le chargement a nécessité le package : ggpubr
fit <- survfit(res.cox, newdata = new_df)
ggsurvplot(fit, data = new_df, conf.int = TRUE, palette = "Dark2",
censor = FALSE, surv.median.line = "hv")
Created on 2020-05-16 by the reprex package (v0.3.0.9001)
Thank you so much for your time, I tried downloaded last version and I tried to run tour script, but I have the same problem. [image: image.png]
Il giorno sab 16 mag 2020 alle ore 16:44 Alboukadel KASSAMBARA < notifications@github.com> ha scritto:
fixed in the latest dev version now (devtools::install_github("kassambara/survminer", build_vignettes = FALSE)), thanks.
Please let me know if it works for you so that we can close this issue.
library("survival")
Fit cox ph
%%%%%%%%%%%%%
res.cox <- coxph(Surv(time, status) ~ age + sex + wt.loss, data = lung) res.cox
> Call:
> coxph(formula = Surv(time, status) ~ age + sex + wt.loss, data = lung)
>
> coef exp(coef) se(coef) z p
> age 0.0200882 1.0202913 0.0096644 2.079 0.0377
> sex -0.5210319 0.5939074 0.1743541 -2.988 0.0028
> wt.loss 0.0007596 1.0007599 0.0061934 0.123 0.9024
>
> Likelihood ratio test=14.67 on 3 df, p=0.002122
> n= 214, number of events= 152
> (14 observations deleted due to missingness)
Survival curves by sex after adjusting by age and wt.loss
%%%%%%%%%%%%%%%%%%%%%%%%
we construct a new data frame with two rows,
one for each value of sex; the other covariates are fixed to their average values
Create the new data
new_df <- with(lung,
data.frame(sex = c(1, 2), age = rep(mean(age, na.rm = TRUE), 2), wt.loss = rep(mean(wt.loss, na.rm = TRUE), 2) )
) new_df
> sex age wt.loss
> 1 1 62.44737 9.831776
> 2 2 62.44737 9.831776
Survival curves with new data
%%%%%%%%%%%%%%%%%%%%%%%%%%%
library(survminer)
> Le chargement a nécessité le package : ggplot2
> Le chargement a nécessité le package : ggpubr
fit <- survfit(res.cox, newdata = new_df)
ggsurvplot(fit, data = new_df, conf.int = TRUE, palette = "Dark2",
censor = FALSE, surv.median.line = "hv")
Created on 2020-05-16 by the reprex package https://reprex.tidyverse.org (v0.3.0.9001)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kassambara/survminer/issues/441#issuecomment-629656951, or unsubscribe https://github.com/notifications/unsubscribe-auth/APMO74LBNY5NDEURFFFN3L3RR2RFNANCNFSM4KIZ2KRQ .
Please, provide your session infos. Here is mine:
library("survival")
library(survminer)
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 3.5.0 (2018-04-23)
#> os macOS Sierra 10.12.6
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate fr_FR.UTF-8
#> ctype fr_FR.UTF-8
#> tz Europe/Paris
#> date 2020-05-16
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> abind 1.4-5 2016-07-21 [1] CRAN (R 3.5.0)
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.2)
#> backports 1.1.5 2019-10-02 [1] CRAN (R 3.5.2)
#> broom 0.5.5 2020-02-29 [1] CRAN (R 3.5.2)
#> callr 3.4.2 2020-02-12 [1] CRAN (R 3.5.2)
#> car 3.0-7 2020-03-11 [1] CRAN (R 3.5.2)
#> carData 3.0-3 2019-11-16 [1] CRAN (R 3.5.2)
#> cellranger 1.1.0 2016-07-27 [1] CRAN (R 3.5.0)
#> cli 2.0.2 2020-02-28 [1] CRAN (R 3.5.2)
#> colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.5.2)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.0)
#> curl 4.3 2019-12-02 [1] CRAN (R 3.5.2)
#> data.table 1.12.8 2019-12-09 [1] CRAN (R 3.5.2)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.0)
#> devtools 2.2.2 2020-02-17 [1] CRAN (R 3.5.2)
#> digest 0.6.25 2020-02-23 [1] CRAN (R 3.5.2)
#> dplyr 0.8.99.9003 2020-05-16 [1] Github (tidyverse/dplyr@b4bc434)
#> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.5.2)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.5.2)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.5.2)
#> forcats 0.5.0 2020-03-01 [1] CRAN (R 3.5.2)
#> foreign 0.8-70 2017-11-28 [1] CRAN (R 3.5.0)
#> fs 1.3.2 2020-03-05 [1] CRAN (R 3.5.2)
#> generics 0.0.2 2018-11-29 [1] CRAN (R 3.5.0)
#> ggplot2 * 3.3.0.9000 2020-05-16 [1] Github (tidyverse/ggplot2@e3fbccc)
#> ggpubr * 0.3.0.999 2020-05-16 [1] local (kassambara/ggpubr@73d0ff6)
#> ggsignif 0.6.0 2019-08-08 [1] CRAN (R 3.5.2)
#> glue 1.3.2 2020-03-12 [1] CRAN (R 3.5.2)
#> gridExtra 2.3 2017-09-09 [1] CRAN (R 3.5.0)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.5.2)
#> haven 2.2.0 2019-11-08 [1] CRAN (R 3.5.2)
#> highr 0.7 2018-06-09 [1] CRAN (R 3.5.0)
#> hms 0.5.3 2020-01-08 [1] CRAN (R 3.5.2)
#> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.5.2)
#> km.ci 0.5-2 2009-08-30 [1] CRAN (R 3.5.0)
#> KMsurv 0.1-5 2012-12-03 [1] CRAN (R 3.5.0)
#> knitr 1.28 2020-02-06 [1] CRAN (R 3.5.2)
#> lattice 0.20-35 2017-03-25 [1] CRAN (R 3.5.0)
#> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 3.5.2)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.0)
#> Matrix 1.2-14 2018-04-13 [1] CRAN (R 3.5.0)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.0)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.5.0)
#> nlme 3.1-137 2018-04-07 [1] CRAN (R 3.5.0)
#> openxlsx 4.1.4 2019-12-06 [1] CRAN (R 3.5.2)
#> pillar 1.4.3 2019-12-20 [1] CRAN (R 3.5.2)
#> pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.5.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.5.2)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.0)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 3.5.2)
#> processx 3.4.2 2020-02-09 [1] CRAN (R 3.5.2)
#> ps 1.3.2 2020-02-13 [1] CRAN (R 3.5.2)
#> purrr 0.3.3 2019-10-18 [1] CRAN (R 3.5.2)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 3.5.2)
#> Rcpp 1.0.4 2020-03-17 [1] CRAN (R 3.5.2)
#> readxl 1.3.1 2019-03-13 [1] CRAN (R 3.5.2)
#> remotes 2.1.1 2020-02-15 [1] CRAN (R 3.5.2)
#> reprex 0.3.0.9001 2020-05-16 [1] Github (tidyverse/reprex@a019cc4)
#> rio 0.5.16 2018-11-26 [1] CRAN (R 3.5.0)
#> rlang 0.4.6.9000 2020-05-16 [1] Github (tidyverse/rlang@683f7a5)
#> rmarkdown 2.1 2020-01-20 [1] CRAN (R 3.5.2)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.0)
#> rstatix 0.5.0.999 2020-05-16 [1] Github (kassambara/rstatix@f762514)
#> scales 1.1.0 2019-11-18 [1] CRAN (R 3.5.2)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.0)
#> stringi 1.4.6 2020-02-17 [1] CRAN (R 3.5.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.5.2)
#> survival * 3.1-12 2020-04-10 [1] CRAN (R 3.5.0)
#> survminer * 0.4.6.999 2020-05-16 [1] local
#> survMisc 0.5.5 2018-07-05 [1] CRAN (R 3.5.0)
#> testthat 2.3.2 2020-03-02 [1] CRAN (R 3.5.2)
#> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.5.2)
#> tidyr 1.0.2 2020-01-24 [1] CRAN (R 3.5.2)
#> tidyselect 1.1.0.9000 2020-05-16 [1] Github (tidyverse/tidyselect@5686b06)
#> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.5.2)
#> vctrs 0.3.0.9000 2020-05-16 [1] Github (r-lib/vctrs@780febb)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.0)
#> xfun 0.13 2020-04-13 [1] CRAN (R 3.5.0)
#> xtable 1.8-2 2016-02-05 [1] CRAN (R 3.5.0)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 3.5.2)
#> zip 2.0.4 2019-09-01 [1] CRAN (R 3.5.2)
#> zoo 1.8-3 2018-07-16 [1] CRAN (R 3.5.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/3.5/Resources/library
Created on 2020-05-16 by the reprex package (v0.3.0.9001)
devtools::session_info() ─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.0.0 (2020-04-24) os macOS Catalina 10.15.3 system x86_64, darwin17.0 ui RStudio language (EN) collate it_IT.UTF-8 ctype it_IT.UTF-8 tz Europe/Rome date 2020-05-16
─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ! package * version date lib source
abind 1.4-5 2016-07-21 [1] CRAN (R 4.0.0)
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
backports 1.1.7 2020-05-13 [1] CRAN (R 4.0.0)
broom 0.5.6 2020-04-20 [1] CRAN (R 4.0.0)
callr 3.4.3 2020-03-28 [1] CRAN (R 4.0.0)
car 3.0-7 2020-03-11 [1] CRAN (R 4.0.0)
carData 3.0-3 2019-11-16 [1] CRAN (R 4.0.0)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.0.0)
cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
curl 4.3 2019-12-02 [1] CRAN (R 4.0.0)
data.table 1.12.8 2019-12-09 [1] CRAN (R 4.0.0)
desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0)
devtools 2.3.0 2020-04-10 [1] CRAN (R 4.0.0)
digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0)
dplyr 0.8.5 2020-03-07 [1] CRAN (R 4.0.0)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.0)
fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.0)
forcats 0.5.0 2020-03-01 [1] CRAN (R 4.0.0)
foreign 0.8-79 2020-04-26 [1] CRAN (R 4.0.0)
fs 1.4.1 2020-04-04 [1] CRAN (R 4.0.0)
gdata 2.18.0 2017-06-06 [1] CRAN (R 4.0.0)
generics 0.0.2 2018-11-29 [1] CRAN (R 4.0.0)
ggplot2 * 3.3.0 2020-03-05 [1] Github (cran/ggplot2@ab97499)
ggpubr * 0.3.0 2020-05-04 [1] CRAN (R 4.0.0)
ggsignif 0.6.0 2019-08-08 [1] CRAN (R 4.0.0)
V glue 1.4.0 2020-05-13 [1] CRAN (R 4.0.0)
gmodels * 2.18.1 2018-06-25 [1] CRAN (R 4.0.0)
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.0)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.0)
gtools 3.8.2 2020-03-31 [1] CRAN (R 4.0.0)
haven 2.2.0 2019-11-08 [1] CRAN (R 4.0.0)
hms 0.5.3 2020-01-08 [1] CRAN (R 4.0.0)
km.ci 0.5-2 2009-08-30 [1] CRAN (R 4.0.0)
KMsurv 0.1-5 2012-12-03 [1] CRAN (R 4.0.0)
knitr 1.28 2020-02-06 [1] CRAN (R 4.0.0)
labeling 0.3 2014-08-23 [1] CRAN (R 4.0.0)
lattice 0.20-41 2020-04-02 [1] CRAN (R 4.0.0)
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0)
lmtest 0.9-37 2019-04-30 [1] CRAN (R 4.0.0)
magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0)
MASS 7.3-51.6 2020-04-26 [1] CRAN (R 4.0.0)
Matrix 1.2-18 2019-11-27 [1] CRAN (R 4.0.0)
memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.0)
mnormt 1.5-7 2020-04-30 [1] CRAN (R 4.0.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.0)
My.stepwise * 0.1.0 2017-06-29 [1] CRAN (R 4.0.0)
nlme 3.1-147 2020-04-13 [1] CRAN (R 4.0.0)
openxlsx 4.1.5 2020-05-06 [1] CRAN (R 4.0.0)
pillar 1.4.4 2020-05-05 [1] CRAN (R 4.0.0)
pkgbuild 1.0.8 2020-05-07 [1] CRAN (R 4.0.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 4.0.0)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0)
processx 3.4.2 2020-02-09 [1] CRAN (R 4.0.0)
ps 1.3.3 2020-05-08 [1] CRAN (R 4.0.0)
psych 1.9.12.31 2020-01-08 [1] CRAN (R 4.0.0)
purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.0)
R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0)
Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 4.0.0)
readxl * 1.3.1 2019-03-13 [1] CRAN (R 4.0.0)
remotes 2.1.1 2020-02-15 [1] CRAN (R 4.0.0)
rio 0.5.16 2018-11-26 [1] CRAN (R 4.0.0)
rlang 0.4.6 2020-05-02 [1] CRAN (R 4.0.0)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.0)
rstatix 0.5.0 2020-04-28 [1] CRAN (R 4.0.0)
rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.0)
scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.0)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.0)
stringi 1.4.6 2020-02-17 [1] CRAN (R 4.0.0)
survival * 3.1-12 2020-04-10 [1] CRAN (R 4.0.0)
V survminer * 0.4.6 2020-05-16 [1] Github (kassambara/survminer@e828309) survMisc 0.5.5 2018-07-05 [1] CRAN (R 4.0.0)
testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.0)
tibble 3.0.1 2020-04-20 [1] CRAN (R 4.0.0)
tidyr 1.0.3 2020-05-07 [1] CRAN (R 4.0.0)
tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.0)
usethis 1.6.1 2020-04-29 [1] CRAN (R 4.0.0)
vcd * 1.4-7 2020-04-02 [1] CRAN (R 4.0.0)
vctrs 0.3.0 2020-05-11 [1] CRAN (R 4.0.0)
withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.0)
xfun 0.13 2020-04-13 [1] CRAN (R 4.0.0)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.0.0)
zip 2.0.4 2019-09-01 [1] CRAN (R 4.0.0)
zoo 1.8-8 2020-05-02 [1] CRAN (R 4.0.0)
[1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library
V ── Loaded and on-disk version mismatch.
Il giorno sab 16 mag 2020 alle ore 16:44 Alboukadel KASSAMBARA < notifications@github.com> ha scritto:
fixed in the latest dev version now (devtools::install_github("kassambara/survminer", build_vignettes = FALSE)), thanks.
Please let me know if it works for you so that we can close this issue.
library("survival")
Fit cox ph
%%%%%%%%%%%%%
res.cox <- coxph(Surv(time, status) ~ age + sex + wt.loss, data = lung) res.cox
> Call:
> coxph(formula = Surv(time, status) ~ age + sex + wt.loss, data = lung)
>
> coef exp(coef) se(coef) z p
> age 0.0200882 1.0202913 0.0096644 2.079 0.0377
> sex -0.5210319 0.5939074 0.1743541 -2.988 0.0028
> wt.loss 0.0007596 1.0007599 0.0061934 0.123 0.9024
>
> Likelihood ratio test=14.67 on 3 df, p=0.002122
> n= 214, number of events= 152
> (14 observations deleted due to missingness)
Survival curves by sex after adjusting by age and wt.loss
%%%%%%%%%%%%%%%%%%%%%%%%
we construct a new data frame with two rows,
one for each value of sex; the other covariates are fixed to their average values
Create the new data
new_df <- with(lung,
data.frame(sex = c(1, 2), age = rep(mean(age, na.rm = TRUE), 2), wt.loss = rep(mean(wt.loss, na.rm = TRUE), 2) )
) new_df
> sex age wt.loss
> 1 1 62.44737 9.831776
> 2 2 62.44737 9.831776
Survival curves with new data
%%%%%%%%%%%%%%%%%%%%%%%%%%%
library(survminer)
> Le chargement a nécessité le package : ggplot2
> Le chargement a nécessité le package : ggpubr
fit <- survfit(res.cox, newdata = new_df)
ggsurvplot(fit, data = new_df, conf.int = TRUE, palette = "Dark2",
censor = FALSE, surv.median.line = "hv")
Created on 2020-05-16 by the reprex package https://reprex.tidyverse.org (v0.3.0.9001)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kassambara/survminer/issues/441#issuecomment-629656951, or unsubscribe https://github.com/notifications/unsubscribe-auth/APMO74LBNY5NDEURFFFN3L3RR2RFNANCNFSM4KIZ2KRQ .
I can see that you don't have the latest dev version of survminer (0.4.6.999).
Please re-start your R session and install the dev version using devtools::install_github("kassambara/survminer", build_vignettes = FALSE)
.
You’re right! sorry! It perfectly works! Thank You so much!
Il giorno sab 16 mag 2020 alle 17:20 Alboukadel KASSAMBARA < notifications@github.com> ha scritto:
I can see that you don't have the latest dev version of survminer (0.4.6.999).
Please re-start your R session and install the dev version using devtools::install_github("kassambara/survminer", build_vignettes = FALSE).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kassambara/survminer/issues/441#issuecomment-629662485, or unsubscribe https://github.com/notifications/unsubscribe-auth/APMO74KEDH5A66PQYXJCOZLRR2VNHANCNFSM4KIZ2KRQ .
thank you for the test and feedback; so we can now close this issue
Hi,
I also have problems with survminer, couldnt load it with R 4.0.0 and now i've tried with 3.6.1 but then it says below:
"Error: package 'ggpubr' could not be loaded In addition: Warning message: package 'ggpubr' was built under R version 3.6.2"
I cant find 3.6.2 now when 4.0.0 is out ...
What should I do?
Many thanks for reply
Loading required package: ggpubr Error: package or namespace load failed for 'ggpubr' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called 'Rcpp' Error: package 'ggpubr' could not be loaded In addition: Warning message: package 'ggpubr' was built under R version 3.6.2
devtools::session_info()
- Session info ------------------------------------------------------------- setting value
version R version 3.6.1 (2019-07-05) os macOS Catalina 10.15.2
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate C
ctype C
tz Europe/Stockholm
date 2020-05-17
And ggsurvplot is not available for neither version 3.6.1 nor 4.0.0. Any hints how to overcome this?
please consider restarting your r session, and then:
1) install ggpubr 2) install the survminer dev version
yes thanks a lot, now it worked!!
Hi,
Thank you for the help on this feed - helped recover original error.
However, since installing ggpubr and installed survminer dev version I get the following:
Error: Failed to install 'survminer' from GitHub: (converted from warning) cannot remove prior installation of package ‘rlang’
Please could you assist, greatly appreciated.
Hi,
I have installed the lastest survminer package 0.4.6.999 using the code below: devtools::install_github("kassambara/survminer", build_vignettes = FALSE)
However, once I load the package, the following error occurred:
library(survminer)
Error: package or namespace load failed for ‘survminer’ in get(method, envir = home):
lazy-load database 'C:/Users/jcaba/Documents/R/win-library/4.0/survminer/R/survminer.rdb' is corrupt
In addition: Warning messages:
1: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4], :
restarting interrupted promise evaluation
2: In get(method, envir = home) :
restarting interrupted promise evaluation
3: In get(method, envir = home) : internal error -3 in R_decompress1
Would really appreciate an advice, thank you!
I can not visualize new data in cox model We can see this example How to plot Cox model with ggsurvplot()?
It used to work, now no and I get
Error in .get_data(fit, data = data, complain = FALSE) : The
dataargument should be provided either to ggsurvfit or survfit.
Or if I use
I get
Error: object of type 'symbol' is not subsettable
survminer_0.4.6