csm_create_state: Create a cropping systems model (CSM) state variable

View source: R/csm_create_state.R

csm_create_stateR Documentation

Create a cropping systems model (CSM) state variable

Description

Create a cropping systems model (CSM) state variable

Usage

csm_create_state(name, definition, units, equation)

Arguments

name

a length-one character vector name of a variable

definition

a length-one character vector that defines the CSM variable

units

a length-one character vector of the units of the CSM variable

equation

an R expression with the equation for the rate of change of the CSM state variable

Value

a list of csm_state objects

Examples


# Define state variables with single call

lv_state <- csm_create_state(
  c("x", "y"),
  definition = c("prey", "predator"),
  units = c("rabbits per square km", "foxes per square km"),
  expression(~alpha*x-beta*x*y, ~delta*x*y-gamma*y))

# Define state variables with multiple calls

lv_state <-
c(
  csm_create_state(
    name = "x",
    definition = "prey",
    units = "rabbits per square km",
    equation = ~alpha*x-beta*x*y),
  csm_create_state(
    name = "y",
    definition = "predator",
    units = "foxes per square km",
    equation = ~delta*x*y-gamma*y)
  )


csmbuilder documentation built on Sept. 19, 2026, 1:06 a.m.