% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update.R
\name{change_type}
\alias{change_type}
\title{Change variable type}
\usage{
change_type(object, name, new_type)
}
\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{new_type}{New variable type; one of \code{'stock'}, \code{'flow'}, \code{'constant'}, \code{'aux'}, \code{'lookup'}, or \code{'func'}. Character vector of the same length as name.}
}
\value{
A stock-and-flow model object of class \code{\link{stockflow}} with the variable type changed throughout the model. Note that changing the type may result in changes to other properties (e.g., a flow must have "to" and/or "from" properties, so these will be added if not already present), and may require changes to the equations of connected variables.
}
\description{
Change the type of a variable in a stock-and-flow model.
}
\examples{
# Start with a simple predator-prey model
sfm <- stockflow("predator_prey")

# Change the birth rate of predators from a constant to an auxiliary
sfm <- change_type(sfm, delta, new_type = "aux")

# This allows us to introduce time-dependence in the birth rate
# (e.g., seasonality with a sine function)
sfm <- sfm |>
  update(delta, eqn = 0.025 + 0.01 * sin(2 * pi * t / 12))
sim <- simulate(sfm)
plot(sim)

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