% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/StudyPopulation.R
\name{plotTimeToEvent}
\alias{plotTimeToEvent}
\title{Plot time-to-event}
\usage{
plotTimeToEvent(
  cohortMethodData,
  population = NULL,
  outcomeId = NULL,
  minDaysAtRisk = 1,
  riskWindowStart = 0,
  startAnchor = "cohort start",
  riskWindowEnd = 0,
  endAnchor = "cohort end",
  censorAtNewRiskWindow = FALSE,
  periodLength = 7,
  numberOfPeriods = 52,
  highlightExposedEvents = TRUE,
  includePostIndexTime = TRUE,
  showFittedLines = TRUE,
  targetLabel = "Target",
  comparatorLabel = "Comparator",
  title = NULL,
  fileName = NULL
)
}
\arguments{
\item{cohortMethodData}{An object of type \link{CohortMethodData} as generated using
\code{\link[=getDbCohortMethodData]{getDbCohortMethodData()}}.}

\item{population}{If specified, this population will be used as the starting
point instead of the cohorts in the \code{cohortMethodData} object.}

\item{outcomeId}{The ID of the outcome. If NULL, no outcome-specific
transformations will be performed.}

\item{minDaysAtRisk}{The minimum required number of days at risk.}

\item{riskWindowStart}{The start of the risk window (in days) relative to the \code{startAnchor}.}

\item{startAnchor}{The anchor point for the start of the risk window. Can be \code{"cohort start"}
or \code{"cohort end"}.}

\item{riskWindowEnd}{The end of the risk window (in days) relative to the \code{endAnchor}.}

\item{endAnchor}{The anchor point for the end of the risk window. Can be \code{"cohort start"}
or \code{"cohort end"}.}

\item{censorAtNewRiskWindow}{If a subject is in multiple cohorts, should time-at-risk be censored
when the new time-at-risk starts to prevent overlap?}

\item{periodLength}{The length in days of each period shown in the plot.}

\item{numberOfPeriods}{Number of periods to show in the plot. The periods are
equally divided before and after the index date.}

\item{highlightExposedEvents}{(logical) Highlight event counts during exposure in a different color?}

\item{includePostIndexTime}{(logical) Show time after the index date?}

\item{showFittedLines}{(logical) Fit lines to the proportions and show them in the plot?}

\item{targetLabel}{A label to us for the target cohort.}

\item{comparatorLabel}{A label to us for the comparator cohort.}

\item{title}{Optional: the main title for the plot.}

\item{fileName}{Name of the file where the plot should be saved, for example
'plot.png'. See \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}} for supported file formats.}
}
\value{
A ggplot object. Use the \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}} function to save to file in a different
format.
}
\description{
Plot time-to-event
}
\details{
Creates a plot showing the number of events over time in the target and comparator cohorts, both before and after
index date. The plot also distinguishes between events inside and outside the time-at-risk period. This requires
the user to (re)specify the time-at-risk using the same arguments as the \code{\link[=createStudyPopulation]{createStudyPopulation()}} function.
Note that it is not possible to specify that people with the outcome prior should be removed, since the plot will
show these prior events.
}
