% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geoms-special.R
\name{geom_km_risktable}
\alias{geom_km_risktable}
\title{Number-at-risk table for a Kaplan-Meier curve}
\usage{
geom_km_risktable(
  mapping = NULL,
  data = NULL,
  breaks = NULL,
  label_size = NULL
)
}
\arguments{
\item{mapping, data}{Standard layer overrides. Map \code{time}, \code{status}, and
(optionally) \code{color}/\code{group} exactly as for \code{\link[=geom_km]{geom_km()}}.}

\item{breaks}{Tick times to report counts at; \code{NULL} (default) picks
about six round numbers spanning the data with \code{pretty()}.}

\item{label_size}{Text size in px.}
}
\value{
A \link{Layer} to add with \code{+}.
}
\description{
Draws the classic "number at risk" strip beneath a survival curve: for
each group, the count of subjects still at risk (\code{time >= tick}) at a
handful of tick times, laid out as an overlay in the bottom ~18\% of the
panel. It is a single layer, not a separate sub-panel — add it
alongside \code{\link[=geom_km]{geom_km()}} on the same plot.
}
\details{
This layer must share the same \code{time}/\code{status}/grouping mapping and
data as the \code{\link[=geom_km]{geom_km()}} layer it accompanies, so the two are trained on
the same time domain and its tick columns line up with the curve above
them.
}
\examples{
set.seed(1)
d <- data.frame(
  t = c(rexp(40, 0.1), rexp(40, 0.07)),
  ev = rbinom(80, 1, 0.7),
  arm = rep(c("placebo", "drug"), each = 40)
)
ggnext(d, aes(time = t, status = ev, color = arm)) +
  geom_km() +
  geom_km_risktable()
}
