#' Title of this function
#' @description A short description of the function
#' @name myfun Name of the function. "Verb" term is preferred.
#' @param par1 Description the first argument. Type of this argument
#' @param par2 The intial (state) values for the ODE. Vector.
#' @return The description of the returned function
#' @examples
#' # Load package and example parameters
#' library(MigrationCommunity)
#' data(example_parameter)
#'
#' # Do something
#' myfunc(par1, par2)
CR_ode <- function(time, state, parameters){
with(as.list(c(state, parameters)), {
# Create a vector of R
RR <- sapply(paste0('R', sprintf("%03d", re)), function(x) eval(parse(text=x)))
# Create a vector of X
XX <- sapply(paste0('X', sprintf("%05d", sp)), function(x) eval(parse(text=x)))
# Resource derivatives
dR <- J * (Rin[re] - RR)
for (i in 1:length(sp)) dR <- dR + stoi[,,sp[i]] %*% (u[,sp[i]] * RR) * XX[i] # Loop through species
# Consumer derivatives
dX <- XX * (t(u[,sp] * w[,sp]) %*% RR - J)
# Return dR and dX
return(list(c(dR,dX)))
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.