Description Usage Arguments Details Value Examples
Initialize a list of equations from a list of strings or R-expressions with
the equations in R-format and sort the equations using their
interdependencies to enable the reuse of evaluated equations in other
equations further in the list.
Abort if any circular dependency is found and warn the user.
Each equation will be an element of the returned sorted list in R-expression
format. Use the eval
function to evaluate each
R-expression in a specified environment.
1 | sdInitEquations(equations, separator = "<-", eqName = c("aux", "eq"))
|
equations |
A list of strings or R-expressions with the equations in R-format. |
separator |
The assignment symbol used in the |
eqName |
The name of the list that will be initialized and sorted, e.g.
'aux' for Can be a vector with all the equations list names that should be considered in the sorting. Default is c('aux', 'eq'). |
The returned list of equations can be: added to the auxiliary equations list
of a sdModelClass
object to replace the use of functions to
calculate intermediary values of the model's system of differential
equations;
or added to the algebraic equations of a sdStaticModelClass
object.
A sorted list of equations in R-expression format.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | const = list(c1 = 2, c2 = 1)
vars = list(k1 = 10, k2 = 2)
auxEquationsStrings <- list("cDiffFrac <- (const$c1 - const$c2) / aux$kDiff",
kDiff = "vars$k1 - vars$k2")
aux <- sdInitEquations(auxEquationsStrings, eqName = 'aux')
print(aux)
#> $kDiff
#> expression(vars$k1 - vars$k2)
#>
#> $cDiffFrac
#> expression((const$c1 - const$c2) / aux$kDiff)
aux$kDiff <- eval(aux$kDiff)
print(eval(aux$cDiff))
#> [1] 0.125
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.