Convert stock-and-flow model to dataframe
as.data.frame.sdbuildR_xmile.Rd
Create a dataframe 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 dataframe.
Usage
# S3 method for class 'sdbuildR_xmile'
as.data.frame(
x,
row.names = NULL,
optional = FALSE,
type = NULL,
name = NULL,
properties = NULL,
...
)
Arguments
- x
Stock-and-flow model 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 dataframe. Must be one or more of 'stock', 'flow', 'constant', 'aux', 'gf', 'model_units', or 'macro'. Defaults to NULL to include all variable types.
- name
Variable names to retain in the dataframe. Defaults to NULL to include all variables.
- properties
Variable properties to retain in the dataframe. Defaults to NULL to include all properties.
- ...
Optional arguments
Examples
as.data.frame(xmile("SIR"))
#> type name eqn
#> 1 stock Susceptible 99999
#> 2 stock Infected 1
#> 3 stock Recovered 0.0
#> 4 constant Total_Population 100000
#> 5 constant Effective_Contact_Rate 2
#> 6 constant Delay 2
#> 7 aux Beta Effective_Contact_Rate / Total_Population
#> 8 aux Lambda Beta * Infected
#> 9 flow Infection_Rate Susceptible * Lambda
#> 10 flow Recovery_Rate Infected / Delay
#> units label to from non_negative conveyor
#> 1 1 Susceptible <NA> <NA> FALSE FALSE
#> 2 1 Infected <NA> <NA> FALSE FALSE
#> 3 1 Recovered <NA> <NA> FALSE FALSE
#> 4 1 Total_Population <NA> <NA> FALSE NA
#> 5 1 Effective_Contact_Rate <NA> <NA> FALSE NA
#> 6 1 Delay <NA> <NA> FALSE NA
#> 7 1 Beta <NA> <NA> FALSE NA
#> 8 1 Lambda <NA> <NA> FALSE NA
#> 9 1 Infection_Rate Infected Susceptible FALSE NA
#> 10 1 Recovery_Rate Recovered Infected FALSE NA
#> eqn_julia
#> 1 99999.0
#> 2 1.0
#> 3 0.0
#> 4 100000.0
#> 5 2.0
#> 6 2.0
#> 7 Effective_Contact_Rate ./ Total_Population
#> 8 Beta .* Infected
#> 9 Susceptible .* Lambda
#> 10 Infected ./ Delay
# Only show stocks
as.data.frame(xmile("SIR"), type = "stock")
#> type name eqn units label non_negative conveyor eqn_julia
#> 1 stock Susceptible 99999 1 Susceptible FALSE FALSE 99999.0
#> 2 stock Infected 1 1 Infected FALSE FALSE 1.0
#> 3 stock Recovered 0.0 1 Recovered FALSE FALSE 0.0
# Only show equation and label
as.data.frame(xmile("SIR"), properties = c("eqn", "label"))
#> type name eqn
#> 1 stock Susceptible 99999
#> 2 stock Infected 1
#> 3 stock Recovered 0.0
#> 4 constant Total_Population 100000
#> 5 constant Effective_Contact_Rate 2
#> 6 constant Delay 2
#> 7 aux Beta Effective_Contact_Rate / Total_Population
#> 8 aux Lambda Beta * Infected
#> 9 flow Infection_Rate Susceptible * Lambda
#> 10 flow Recovery_Rate Infected / Delay
#> label
#> 1 Susceptible
#> 2 Infected
#> 3 Recovered
#> 4 Total_Population
#> 5 Effective_Contact_Rate
#> 6 Delay
#> 7 Beta
#> 8 Lambda
#> 9 Infection_Rate
#> 10 Recovery_Rate