| model_units | R Documentation |
A large library of units already exists, but you may want to define your own custom units. Use model_units() to add, change, or erase custom units from a stock-and-flow model. Custom units may be new base units, or may be defined in terms of other (custom) units. See u() for more information on the rules of specifying units. Note that units are only supported in Julia, not in R.
model_units(sfm, name, eqn = "1", doc = "", erase = FALSE, change_name = NULL)
sfm |
Stock-and-flow model, object of class |
name |
Name of unit. A character vector. |
eqn |
Definition of unit. String or vector of unit definitions. Defaults to "1" to indicate a base unit not defined in terms of other units. |
doc |
Documentation of unit. |
erase |
If TRUE, remove model unit from the model. Defaults to FALSE. |
change_name |
New name for model unit. Defaults to NULL to indicate no change. |
A stock-and-flow model object of class sdbuildR_xmile
unit_prefixes()
# Units are only supported with Julia
sfm <- xmile("Crielaard2022")
sfm <- model_units(sfm, "BMI", eqn = "kg/m^2", doc = "Body Mass Index")
# You may also use words rather than symbols for the unit definition.
# The following modifies the unit BMI:
sfm <- model_units(sfm, "BMI", eqn = "kilogram/meters^2")
# Remove unit:
sfm <- model_units(sfm, "BMI", erase = TRUE)
# Unit names may be changed to be syntactically valid and avoid overlap:
sfm <- model_units(xmile(), "C0^2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.