Kaplan-Meier plot with number of subjects at risk below
plot_km(
formula,
data,
test = TRUE,
xy.pvalue = NULL,
conf.int = FALSE,
times.print = NULL,
nrisk.labels = NULL,
legend = NULL,
xlab = NULL,
ylab = NULL,
ylim = c(0, 1.02),
left = 4.5,
bottom = 5,
cex.mtext = par("cex"),
lwd = 2,
lty = 1,
col = NULL,
...
)None
same formula than in survfit (Surv(time,cens)~group or Surv(time,cens)~1), where cens must equal to 0 (censorship) or 1 (failure)
data frame with time, cens and group
boolean, TRUE to compute and display the p-value of the log-rank test
numeric vector of length 2, coordinates where to display the p-value of the log-rank test
boolean, TRUE to display the confidence interval of the curve(s)
numeric vector, times at which to display the numbers of subjects at risk
character vector to modify the levels of group in the table below the curve(s)
character string ("bottomright" for example) or numeric vector (c(x,y)), where to place the legend of the curve(s)
character string, label of the time axis
character string, label of the y axis
numeric vector of length 2, minimum and maximum of the y-axis
integer, size of left margin
integer, number of lines in addition of the table below the graph
numeric, size of the numbers of subjects at risk
width of the Kaplan-Meier curve(s)
type of the Kaplan-Meier curve(s)
color(s) of the Kaplan-Meier curve(s)
other arguments to be passed in plot.survfit
Hugo Varet
cgd$time=cgd$tstop-cgd$tstart
plot_km(Surv(time,status)~sex,data=cgd,col=c("blue","red"))
Run the code above in your browser using DataLab