% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/extend_exp_duration.R
\name{extend_exp_duration}
\alias{extend_exp_duration}
\title{Add cumulative count and summary stats for categories for exposure duration analysis}
\usage{
extend_exp_duration(
  outdata,
  category_section_label = paste0(metalite::collect_adam_mapping(outdata$meta,
    outdata$parameter)$label, " (extend)"),
  duration_category_list = extract_duration_category_ranges(duration_category_labels),
  duration_category_labels =
    levels(outdata$meta$data_population[[metalite::collect_adam_mapping(outdata$meta,
    outdata$parameter)$vargroup]])
)
}
\arguments{
\item{outdata}{An \code{outdata} object created by \code{\link[=prepare_exp_duration]{prepare_exp_duration()}}.}

\item{category_section_label}{A character value of section label.
If \code{NULL}, the parameter label is used with "(cumulative)".}

\item{duration_category_list}{A list of duration category ranges.
Must be real numbers and may overlap or be mutually exclusive.
A list should be in the form of \code{list(c(low1, high1), c(low2, high2), ...)}.
If \code{NA} is included in the range, it is treated as \code{-Inf} or \code{Inf}.
The range is defined as \verb{low <= x < high} for each.}

\item{duration_category_labels}{A character vector of internal labels.
Labels to be displayed for the duration_category_list values.
Must be the same length as duration_category_list.}
}
\value{
A list of analysis raw datasets.
}
\description{
Add cumulative count and summary stats for categories for exposure duration analysis
}
\examples{
meta <- metalite::meta_adam(
  population = metalite_sl_adexsum,
  observation = metalite_sl_adexsum
) |>
  metalite::define_plan(metalite::plan(
    analysis = "exp_dur", population = "apat",
    observation = "apat", parameter = "expdur"
  )) |>
  metalite::define_population(
    name = "apat", group = "TRTA", subset = APERIOD == 1 & AVAL > 0
  ) |>
  metalite::define_parameter(
    name = "expdur", subset = PARAMCD == "TRTDURD", var = "AVAL",
    label = "Exposure Duration (Days)", vargroup = "EXDURGR"
  ) |>
  metalite::define_analysis(
    name = "exp_dur", title = "Summary of Exposure Duration",
    label = "exposure duration table"
  ) |>
  metalite::meta_build()

outdata <- meta |> prepare_exp_duration()
outdata |>
  extend_exp_duration(
    duration_category_list = list(c(1, NA), c(7, NA), c(28, NA), c(12 * 7, NA), c(24 * 7, NA)),
    duration_category_labels = c(">=1 day", ">=7 days", ">=28 days", ">=12 weeks", ">=24 weeks")
  )
}
