Hello, I am trying to plot a survival curve for the following sample data:
structure(list(Shape = c("Type1", "Type1", "Type2", "Type3",
"Type4", "Type4"), OS = c(5L, 2L, 15L, 29L, 1L, 4L), OS_event = c(0L,
0L, 0L, 1L, 1L, 0L)), class = "data.frame", row.names = c(NA,
-6L))
And here is my code for the plot:
library(survival) # Load survival curve package
OS <- survfit(Surv(Book1$OS,Book1$OS_event)~Book1$Shape)
# Run the following together:
plot(OS, col=c(1:5), xlab="Time (months)", ylab="Survival Probability", ylim= c(0, 1.0))
legend(25,0.5, c("Type1","Type2","Type3","Type4"), col=(1:5),lwd=1.0)
However, I would like to generate the survival plot such that I can compare the combined Type1 and Type2 curves against combined Type3 and Type4 curves - so there should be 2 curves in total instead of four. Is there a way to modify my current code in order to achieve this result?
Thanks!