% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update.R
\name{auxiliary}
\alias{auxiliary}
\alias{aux}
\title{Add or modify auxiliaries}
\usage{
auxiliary(object, name, eqn = 0, label = name, doc = "", non_negative = FALSE)

aux(object, name, eqn = 0, label = name, doc = "", non_negative = FALSE)
}
\arguments{
\item{object}{Stock-and-flow model, object of class \code{\link{stockflow}}.}

\item{name}{Variable name. Accepts a bare symbol (e.g., \code{population}), a string (\code{"population"}), or a vector via \code{c()} (e.g., \code{c(a, b)} or \code{c("a", "b")}). Use \verb{!!} to inject from a variable.}

\item{eqn}{Equation (or initial value in the case of stocks). Accepts a bare expression (e.g., \code{a * b + 1}), a string (\code{"a * b + 1"}), or a numeric value. Use \verb{!!} to inject from a variable. Defaults to \code{0}.}

\item{label}{Name of variable used for plotting. Defaults to the same as name.}

\item{doc}{Description of variable. Defaults to \code{""} (no description).}

\item{non_negative}{If TRUE, variable is enforced to be non-negative (i.e., strictly 0 or positive). Defaults to \code{FALSE}.}
}
\value{
A stock-and-flow model object of class \code{\link{stockflow}}
}
\description{
Auxiliaries are dynamic variables used for intermediate calculations in the
system. \code{\link[=auxiliary]{auxiliary()}} adds or changes an auxiliary variable. This is a convenience
wrapper around \code{\link[=update]{update()}} with \code{type = "aux"}. See the \strong{Auxiliaries} section
of \code{\link[=update.stockflow]{update()}} for more details.
}
\examples{

# Create an auxiliary for an intermediate calculation
sfm <- stockflow() |>
  stock(population, eqn = 100) |>
  constant(carrying_capacity, eqn = 1000) |>
  auxiliary(density, eqn = population / carrying_capacity, label = "Density")

}
\seealso{
\code{\link[=update.stockflow]{update()}}, \code{\link[=discard]{discard()}}, \code{\link[=change_name]{change_name()}}
}
\concept{build}
