Description Usage Arguments Value Author(s) Examples
Creates a Kaplan-Meier plot based on a survfit object
| 1 2 3 4 | 
| fit | A survfit object that we should plot | 
| lwd | Line width | 
| xmax | What is the upper limit of the X axis? The default will plot all data. | 
| xbreaks | A numeric vector. Where should the breaks in the X axis be? The default will give ggplot's default breaks. | 
| ylim | A numeric vector of length 2. Which are the Y axis limits? | 
| ci | A logical scalar. Should confidence intervals be plotted? | 
| cuminc | A logical scalar. Should cumulative incidence be plotted (default), or should be survival be plotted instead (cuminc = FALSE)? | 
| y_percent | A logical scalar. Should the Y axis display percentages? | 
| split_legend_labels | A logical scalar. Should the legends labels be split, i.e. removing the "<variable_name>=" for each stratum? | 
| legend.title | What title should the legend have? By default it will take the value that was split if split_legend_labels was used; otherwise it will take the value "strata" | 
| legend.position | Where should the legend be drawn? Possible answers are: "top", "bottom", "left", "right"; or if you want to skip putting a legend on the plot: "none" | 
Returns a ggplot object
Daniel Lindholm
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library(survsup); library(ggplot2); library(dplyr); library(survival)
retinopathy %>%
    survfit(Surv(futime, status) ~ trt, data = .) %>%
   plot_survfit()
retinopathy %>%
    survfit(Surv(futime, status) ~ trt, data = .) %>%
   plot_survfit(ci = TRUE, cuminc = FALSE)
# Since a ggplot object is returned,
# you can tweak as you wish
# (in this case with multiple labels):
mgus2 %>%
     survfit(Surv(futime, death) ~ sex, data = .) %>%
     plot_survfit(cuminc = FALSE) %>%
     nar(flip = TRUE) %>%
     hcl_rainbow()+  # <--- Notice + sign here!
     labs(title = "This is an excessively long title",
     	subtitle = "This is a subtitle",
     	x = "Time (days)",
     	y = "Survival (%)",
     	caption = "(This is a demo)")
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.