I wanted to plot a survival curve using the following data. I called the data file as A.txt and the object A
A <- read.table(text = "
Time Status Group
8 1 A
8 1 A
8 1 A
9 1 A
9 1 A
9 1 A
15 0 A
15 0 A
7 1 B
7 1 B
8 1 B
9 1 B
10 1 B
10 1 B
15 0 B
15 0 B", header = TRUE)
I tried to plot a survival curve using this code:
title(main="Trial for Survival Curve")
fit <- survfit(Surv(Time, Status) ~ Group, data = A)
par(col.lab="red")
legend(10, .9, c("A", "B"), pch=c(2,3),col=2:3)
plot(fit, lty=2:3, col=2:3,lwd=5:5, xlab='Time(Days)',
ylab='% Survival',mark.time=TRUE,mark=2:3)
I would like to put marks (triangle for A
and "+"
for B
) every time when survival % decreases for instance at Day 7 and Day 8. I want this labeling throughout the graph, but it adds the labels only at the end of the experiment.
?plot
and itstype="s"
as well as at?stepfun
. And do learn to make examples with code so your answers are more helpful. – IRTFM