as.data.frame.sdbuildR_xmile: Convert stock-and-flow model to data frame

View source: R/build_xmile.R

as.data.frame.sdbuildR_xmileR Documentation

Convert stock-and-flow model to data frame

Description

Create a data frame with properties of all model variables, model units, and macros. Specify the variable types, variable names, and/or properties to get a subset of the data frame.

Usage

## S3 method for class 'sdbuildR_xmile'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  type = NULL,
  name = NULL,
  properties = NULL,
  ...
)

Arguments

x

A stock-and-flow model object of class sdbuildR_xmile.

row.names

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

optional

Ignored parameter.

type

Variable types to retain in the data frame. Must be one or more of 'stock', 'flow', 'constant', 'aux', 'gf', 'macro', or 'model_units'. Defaults to NULL to include all types.

name

Variable names to retain in the data frame. Defaults to NULL to include all variables.

properties

Variable properties to retain in the data frame. Defaults to NULL to include all properties.

...

Optional arguments

Value

A data.frame with one row per model component (variable, unit definition, or macro). Common columns include type (component type), name (variable name), eqn (equation), units (units of measurement), and label (descriptive label). Additional columns may include to, from, non_negative, and others depending on variable types. The exact columns returned depend on the type and properties arguments. Returns an empty data.frame if no components match the filters.

Examples

as.data.frame(xmile("SIR"))

# Only show stocks
as.data.frame(xmile("SIR"), type = "stock")

# Only show equation and label
as.data.frame(xmile("SIR"), properties = c("eqn", "label"))


sdbuildR documentation built on Nov. 19, 2025, 5:07 p.m.