## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(landmarked)
library(survminer)
library(dplyr)

## ----fig.width=6, fig.height=4------------------------------------------------
data = survival::lung |> 
  mutate(months = time/30.4375) |> 
  select(months,status, sex)

fit = survival::survfit(survival::Surv(months, status) ~ sex, data)

ggsurvplot(
  fit,    
  data = data, 
  ylab="survival (%)",
  xlab="Time (months)",
  break.time.by = 6,
  conf.int = FALSE,
  legend = "none",
  surv.scale = "percent",
  xlim= c(0,25),
  surv.median.line = "hv",
  palette = c("#2E9FDF","#E7B800"),
  #Standard configuration
  risk.table = c("nrisk_cumcensor"),
  ggtheme = theme_survminer()+theme(),
  tables.theme = theme_void() + theme(plot.title = element_text(size =10)),
  risk.table.y.text.col = T, 
  risk.table.y.text = FALSE, 
  axes.offset=FALSE,
  risk.table.fontsize =3,
  tables.height=0.2
)


## ----fig.width=6, fig.height=4------------------------------------------------
ggsurvplotlm(
  fit,                     
  landmark_time = 6,
  landmark_label = "Landmark",
  data = data,  
  ylab="survival (%)",
  xlab="Time (months)",
  break.time.by = 6,
  conf.int = FALSE,
  legend = "none",
  surv.scale = "percent",
  xlim= c(0,25),
  surv.median.line = "hv",
  palette = c("#2E9FDF","#E7B800"),
  ggtheme = theme_survminer()+theme(),
  axes.offset=FALSE
)

