I am plotting a survival curve by ggsurvplot()
, to transform days in years I use as argument xscale="d_y"
. I have tried also xscale=365.25
as suggested by the documentation.
The problem is that time axis is automatically labelled but not as I expected at year 1, 2, 3...
Instead I get 0.55, 1.1, and so on. How can I label exactly at every round year?
Find the code below
install.packages('survMisc')
library("survminer")
time <- sample(200:500, 20, replace=T)
status <-sample(0:1, 20, replace=T)
group<-c(rep("A", 10), rep("B", 10))
df<-data.frame (time, status, group)
fit2 <- survfit(Surv(time, status) ~ group,data = df)
ggsurvplot(fit2, xscale="d_y")
Your data time
doesn't go more than 1.34 years. But add break.x.by=365
and you'll have he scale you want.
install.packages('survMisc')
library("survminer")
time <- sample(200:500, 20, replace=T)
status <-sample(0:1, 20, replace=T)
group<-c(rep("A", 10), rep("B", 10))
df<-data.frame (time, status, group)
fit2 <- survfit(Surv(time, status) ~ group,data = df)
ggsurvplot(fit2, xscale="d_y", break.x.by=365)