% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
\name{as.data.frame.simulate_stockflow}
\alias{as.data.frame.simulate_stockflow}
\title{Create data frame of simulation results}
\usage{
\method{as.data.frame}{simulate_stockflow}(
  x,
  row.names = NULL,
  optional = FALSE,
  direction = "long",
  vars = NULL,
  type = NULL,
  ...
)
}
\arguments{
\item{x}{Output of \code{\link[=simulate.stockflow]{simulate()}}.}

\item{row.names}{NULL or a character vector giving the row names for the data frame. Missing values are not allowed.}

\item{optional}{Ignored parameter.}

\item{direction}{Format of data frame, either "long" (default) or "wide".}

\item{vars}{Variable names to retain in the data frame. Defaults to \code{NULL} to include all variables.}

\item{type}{Variable types to retain in the data frame. Must be one or more of 'stock', 'flow', 'constant', 'aux', 'lookup', or 'func'. Defaults to \code{NULL} to include all types.}

\item{...}{Optional parameters}
}
\value{
A data.frame with simulation results. For \code{direction = "long"} (default),
the data frame has three columns: \code{time}, \code{variable}, and \code{value}.
For \code{direction = "wide"}, the data frame has columns \code{time} followed by
one column per variable.
}
\description{
Convert simulation results to a data.frame.
}
\examples{
sfm <- stockflow("sir")
sim <- simulate(sfm)
df <- as.data.frame(sim)
head(df)

# Get results in wide format
df_wide <- as.data.frame(sim, direction = "wide")
head(df_wide)

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