plot_km function

Kaplan-Meier plot with number of subjects at risk below

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, ... )

Arguments

  • 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 test
  • xy.pvalue: numeric vector of length 2, coordinates where to display the p-value of the log-rank test
  • conf.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 risk
  • nrisk.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 axis
  • ylab: character string, label of the y axis
  • ylim: numeric vector of length 2, minimum and maximum of the y-axis
  • left: integer, size of left margin
  • bottom: integer, number of lines in addition of the table below the graph
  • cex.mtext: numeric, size of the numbers of subjects at risk
  • lwd: 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

Returns

None

Examples

cgd$time=cgd$tstop-cgd$tstart plot_km(Surv(time,status)~sex,data=cgd,col=c("blue","red"))

Author(s)

Hugo Varet

  • Maintainer: Hugo Varet
  • License: GPL (>= 2)
  • Last published: 2025-03-24

Useful links