Description Usage Arguments Value Examples
The ordinary differential equations that describe the consumer and resource interactions.
1 |
time |
time sequence for which output is wanted; the first value of times must be the initial time. |
state |
the initial (state) values for the ODE, a vector. |
parameters |
parameters passed to ODE. |
a matrix of class deSolve.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Load packages and example parameters
library(tidyverse)
library(deSolve)
data(example_parameter)
# Create species pool
pool_build()
# Time sequence
time <- seq(0, 100, by = 1)
# Parameters: a named vector
sp <- 1:S
re <- 1:P
parameters <- list(sp = sp, re = re, J = J, Rin = Rin, P = P, S = S, u = u, w = w, m = m, stoi = stoi)
# Initial condition: a named vector
state <- c(
setNames(rep(.1, P), paste0("R", sprintf("%03d", 1:P))),
setNames(rep(1, length(sp)), paste0("X", sprintf("%05d", sp)))
)
# Run ode
result <- ode(y = state, times = time, func = CR_ode, parms = parameters)
# Plot
result %>%
as.tibble() %>%
gather("index", "value", -1) %>%
ggplot(aes(x = time, y = value, color = index, lty = substr(index, 1, 1))) +
geom_line()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.