if(!require(devtools)) install.packages("devtools")
## Loading required package: devtools
devtools::install_github("kassambara/survminer", build_vignettes = FALSE)
## Skipping install of 'survminer' from a github remote, the SHA1 (51d35d04) has not changed since last install.
##   Use `force = TRUE` to force installation
library(survminer)
## Loading required package: ggplot2
## Loading required package: ggpubr
## Loading required package: magrittr
library("survminer")


km<- read.csv("matched data.csv")
require("survival")
## Loading required package: survival
fit <- survfit(Surv(sm, death) ~ an_type, data = km)


ggsurvplot(
  fit,                     # survfit object with calculated statistics.
  data = km,             # data used to fit survival curves.
  risk.table = TRUE,       # show risk table.
  pval = FALSE,             # show p-value of log-rank test.
  conf.int = TRUE,         # show confidence intervals for 
  # point estimates of survival curves.
  xlim = c(0,60),  
  ylim = c(0.85,1),# present narrower X axis, but not affect
  # survival estimates.
  xlab = "Time (month)", # customize X axis label.
  ylab = "Survival probability",
  legend.labs = 
    c("INHA", "TIVA"),
  break.time.by = 10,     # break X axis in time intervals by 60.
  ggtheme = theme_light(), # customize plot and risk table with a theme.
  risk.table.y.text.col = T, # colour risk table text annotations.
  risk.table.y.text = FALSE, # show bars instead of names in text annotations
  surv.median.line = "hv")
## Warning in .add_surv_median(p, fit, type = surv.median.line, fun = fun, :
## Median survival not reached.