% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.gg_survival.R
\name{plot.gg_survival}
\alias{plot.gg_survival}
\title{Plot a \code{\link{gg_survival}} object.}
\usage{
\method{plot}{gg_survival}(
  x,
  type = c("surv", "cum_haz", "hazard", "density", "mid_int", "life", "proplife"),
  error = c("shade", "bars", "lines", "none"),
  label = NULL,
  ...
)
}
\arguments{
\item{x}{\code{\link{gg_survival}} or a survival \code{\link{gg_rfsrc}}
object created from a \code{\link[randomForestSRC]{rfsrc}} object}

\item{type}{"surv", "cum_haz", "hazard", "density", "mid_int", "life", "proplife"}

\item{error}{"shade", "bars", "lines" or "none"}

\item{label}{Modify the legend label when gg_survival has stratified samples}

\item{...}{Additional arguments forwarded to \code{geom_step()}. When
\code{alpha} is supplied it is passed to the step geom and a halved
value is used for the ribbon overlay.}
}
\value{
A \code{ggplot} object. The y-axis shows the chosen \code{type}
(e.g. survival probability for \code{"surv"}) and the x-axis shows time.
Confidence shading, bars, or lines are added when the input object carries
confidence-interval columns.
}
\description{
Draws a Kaplan-Meier (or Nelson-Aalen) survival curve from a
\code{\link{gg_survival}} object.  You can overlay a confidence envelope
around the curve using \code{error}: \code{"shade"} fills the area between
the pointwise confidence limits, \code{"lines"} draws them as dashed step
functions, and \code{"bars"} shows them as error bars.  When \code{gg_survival}
was called with a \code{by} argument, each group gets its own step function
and the \code{label} argument renames the legend.
}
\details{
The \code{type} argument selects which quantity to plot on the y-axis --
survival probability (\code{"surv"}) is the default, but cumulative hazard,
density, and several transformed scales are available for the cases where a
linear scale reveals more about the tails.
}
\examples{
## -------- pbc data
data(pbc, package = "randomForestSRC")
pbc$time <- pbc$days / 364.25

# This is the same as kaplan
gg_dta <- gg_survival(
  interval = "time", censor = "status",
  data = pbc
)

plot(gg_dta, error = "none")
plot(gg_dta)

# Stratified on treatment variable.
gg_dta <- gg_survival(
  interval = "time", censor = "status",
  data = pbc, by = "treatment"
)

plot(gg_dta, error = "none")
plot(gg_dta)
plot(gg_dta, label = "treatment")

# ...with smaller confidence limits.
gg_dta <- gg_survival(
  interval = "time", censor = "status",
  data = pbc, by = "treatment", conf.int = .68
)

plot(gg_dta, error = "lines")
plot(gg_dta, label = "treatment", error = "lines")

# ...with smaller confidence limits.
gg_dta <- gg_survival(
  interval = "time", censor = "status",
  data = pbc, by = "sex", conf.int = .68
)

plot(gg_dta, error = "lines")
plot(gg_dta, label = "sex", error = "lines")

}
\seealso{
\code{\link{gg_survival}}, \code{\link{kaplan}},
\code{\link{nelson}}, \code{\link{gg_rfsrc}}
}
