Description Usage Arguments Value Examples
This function takes a named vector as initial community, simulates based on CR_ode function, and reports the output result matrix.
1 | CR_model(community = community, time_limit = 100, time_step = 1)
|
community |
the initial state of species and resource in a community. A named vector. |
time_limit |
time limit for ode. |
time_step |
time step for ode. |
a deSolve matrix
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 | # Load example parameters
data(example_parameter)
# Build regional species pool
pool_build()
# Create a community, a named vector
set.seed(1)
species <- sample(1:S_pool, S, replace = FALSE) %>% sort()
community <-
c(
setNames(c(rep(1, P)), paste0("R", sprintf("%03d", 1:P))),
setNames(c(rep(.1, length(species))), paste0("X", sprintf("%05d", species)))
)
# Run ode
result <- CR_model(community = community, time_limit = 100, time_step = 1)
# Plot
result %>%
as.tibble() %>%
gather("index", "value", -1) %>%
ggplot(aes(x = time, y = value, color = index, lty = substr(index, 1, 1))) +
geom_line() +
theme(legend.position = "none")
# Main function for running consumer-resource model
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.