Learn R Programming

sdbuildR (version 2.0.0)

as.data.frame.simulate_stockflow: Create data frame of simulation results

Description

Convert simulation results to a data.frame.

Usage

# S3 method for simulate_stockflow
as.data.frame(x, row.names = NULL, optional = FALSE, direction = "long", ...)

Value

A data.frame with simulation results. For direction = "long" (default), the data frame has three columns: time, variable, and value. For direction = "wide", the data frame has columns time followed by one column per variable.

Arguments

x

Output of simulate().

row.names

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

optional

Ignored parameter.

direction

Format of data frame, either "long" (default) or "wide".

...

Optional parameters

See Also

simulate(), stockflow()

Examples

Run this code
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)

Run the code above in your browser using DataLab