% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/survival_quantiles.R
\name{survival_quantiles}
\alias{survival_quantiles}
\title{Kaplan-Meier survival quantile table}
\usage{
survival_quantiles(
  data,
  time,
  event,
  by = NULL,
  probs = c(0.25, 0.5, 0.75),
  digits = 1,
  format = c("flextable", "gt", "tibble"),
  theme = c("minimal")
)
}
\arguments{
\item{data}{A \code{data.frame} containing survival time and event status.}

\item{time}{Survival follow-up time. Quoted and bare names are accepted.}

\item{event}{Event indicator. Quoted and bare names are accepted. Numeric
\code{0/1}, numeric \code{1/2}, logical, character, and factor variables
are accepted. For two-level character or factor variables, the second level
is treated as the event.}

\item{by}{Optional grouping variable for separate Kaplan-Meier quantiles.
Quoted and bare names are accepted.}

\item{probs}{Numeric vector of event-time quantiles to estimate. The default
\code{c(0.25, 0.5, 0.75)} reports the 25th percentile, median, and 75th
percentile event times.}

\item{digits}{Number of digits for survival time summaries.}

\item{format}{Output format. One of \code{"flextable"} (default),
\code{"gt"}, or \code{"tibble"}.}

\item{theme}{Table styling preset.}
}
\value{
A list of class \code{c("gtregression","survival_quantiles", ...)}
with elements:
\describe{
  \item{\code{table}}{A \code{flextable}, \code{gt_tbl}, or \code{NULL}
  when \code{format = "tibble"}.}
  \item{\code{table_body}}{Tibble with Kaplan-Meier quantiles.}
  \item{\code{table_display}}{Display data frame used to render the table.}
  \item{\code{fit}}{Fitted \code{survfit} object.}
  \item{\code{time,event,by,probs,format,source}}{Metadata fields.}
}
}
\description{
Estimate Kaplan-Meier survival time quantiles, such as the 25th percentile,
median, and 75th percentile survival times.
}
\details{
A probability of \code{0.50} is the median event time: the estimated time by
which 50% of participants have had the event, corresponding to 50% survival.
A probability of \code{0.25} is the time by which 25% have had the event,
corresponding to 75% survival. If a quantile is not reached during observed
follow-up, the display table shows \code{"Not reached"}.
}
\examples{
lung_data <- data_lungcancer
lung_data$trt <- factor(lung_data$trt, levels = c(1, 2),
                        labels = c("Standard", "Test"))

survival_quantiles(
  data = lung_data,
  time = time,
  event = status,
  by = trt
)

survival_quantiles(
  data = lung_data,
  time = "time",
  event = "status",
  probs = c(0.25, 0.5),
  format = tibble
)

}
