Help with survival curve

Could someone help me improve my below coding as I don't think that I am quite getting the answer to this question? It is based on an R database VA.

"using the td data frame below and ggplot, produce a single graphic that allows comparison of survival curves by treatment, stratified by cell type"

This is the best that I was able to do but I suspect they want something better/different:

R script:

data(VA)
library(survival)
library(broom)
VA.surv = survfit(Surv(VA$stime,VA$status) ~ VA$treat + VA$cell)
td = tidy(VA.surv)
library(ggplot2)
ggplot(td, aes(time, estimate)) + geom_line() +
  geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .2) +
  ggtitle(label = "Kaplan-Meier survival curves by cell type and treatment") +
  labs(x = "Time (Days)", y = "Survival", caption = "Caption") +
  theme_publication()+
  theme(plot.title=element_text(size=16,face="bold"),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(),
        axis.text.x=element_text(face="bold"),
        axis.title=element_text(size=12,face="bold"),
        strip.text.y = element_text(vjust = 1,angle=180,face="bold"))+
  facet_wrap(~strata)```

Any thoughts on how I could improve this? I would be most grateful!

Best wishes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.