0

I'm running the survival analysis in R from the following tutorial: https://www.emilyzabor.com/tutorials/survival_analysis_in_r_tutorial.html#Part_1:_Introduction_to_Survival_Analysis

I got an error while running the following lines of code to get Kaplan-Meier plots.

survfit2(Surv(time, status) ~ 1, data = lung) %>% 
  ggsurvfit() +
  labs(
    x = "Days",
    y = "Overall survival probability"
  )

Error in ggsurvfit(.) : could not find function "ggsurvfit"

Could anyone help me figure out how to fix the error? I'd appreciate it!

beth_9
  • 103
  • 5
  • Did you loaded the package? `library(ggsurvfit)` – Vinícius Félix Dec 02 '22 at 01:01
  • I just did and I got this error: Error in library(ggsurvfit) : there is no package called ‘ggsurvfit’ I should install it first though, right? I couldn't find the ggsurvfit package. – beth_9 Dec 02 '22 at 01:05

1 Answers1

0

It seems you haven't downloaded the package, so you can use

install.packages("ggsurvfit")

or

remotes::install_github("ddsjoberg/ggsurvfit")

*the second command also requires a package (remotes).

Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32