# Simple function
sfm <- stockflow() |>
custom_func(double, eqn = "function(x) x * 2") |>
constant(a, eqn = double(2))
# Function with defaults
sfm <- stockflow() |>
custom_func(scale, eqn = "function(x, factor = 10) x * factor") |>
constant(b, eqn = scale(2))
# If the logistic() function did not exist, you could create it yourself:
sfm <- stockflow() |>
custom_func(my_logistic, eqn = "function(x, slope = 1, midpoint = .5){
1 / (1 + exp(-slope*(x-midpoint)))
}") |>
constant(c_, eqn = my_logistic(2, slope = 50))
Run the code above in your browser using DataLab