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, ... )
formula
: 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
: data frame with time
, cens
and group
test
: boolean, TRUE
to compute and display the p-value of the log-rank testxy.pvalue
: numeric vector of length 2, coordinates where to display the p-value of the log-rank testconf.int
: boolean, TRUE
to display the confidence interval of the curve(s)times.print
: numeric vector, times at which to display the numbers of subjects at risknrisk.labels
: character vector to modify the levels of group
in the table below the curve(s)legend
: character string ("bottomright"
for example) or numeric vector (c(x,y)
), where to place the legend of the curve(s)xlab
: character string, label of the time axisylab
: character string, label of the y axisylim
: numeric vector of length 2, minimum and maximum of the y-axisleft
: integer, size of left marginbottom
: integer, number of lines in addition of the table below the graphcex.mtext
: numeric, size of the numbers of subjects at risklwd
: width of the Kaplan-Meier curve(s)lty
: type of the Kaplan-Meier curve(s)col
: color(s) of the Kaplan-Meier curve(s)...
: other arguments to be passed in plot.survfit
None
cgd$time=cgd$tstop-cgd$tstart plot_km(Surv(time,status)~sex,data=cgd,col=c("blue","red"))
Hugo Varet
Useful links