% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update.R
\name{flow}
\alias{flow}
\title{Add or modify flows}
\usage{
flow(
  object,
  name,
  eqn = 0,
  to = NULL,
  from = NULL,
  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{to}{Target of flow. Accepts a bare symbol or string. Must be a stock in the model. Defaults to \code{NULL} to indicate no target.}

\item{from}{Source of flow. Accepts a bare symbol or string. Must be a stock in the model. Defaults to \code{NULL} to indicate no source.}

\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{
Flows move material and information through the system, increasing or
decreasing stocks. \code{\link[=flow]{flow()}} adds or changes a flow variable. This is a
convenience wrapper around \code{\link[=update]{update()}} with \code{type = "flow"}. See the
\strong{Flows} section of \code{\link[=update]{update()}} for more details.
}
\examples{

# Create a flow into a stock
sfm <- stockflow() |>
  stock(population, eqn = 100) |>
  flow(births, eqn = population * 0.1, to = population) |>
  flow(deaths, eqn = population * 0.05, from = population)

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