#' ---
#' title: "Simple growth difference equation model"
#' author: "Richard Reeve"
#' date: '`r format(Sys.Date(), "%B %d %Y")`'
#' output: html_document
#' ---
#'
#' ### Function: step_simple_growth() - A simple deterministic exponential growth model
#'
#' Run one step of a simple deterministic exponential growth model
#'
#' Arguments:
#'
#' - current.population -- the population count now
#'
#' - growth.rate -- the growth rate
#'
#' Returns:
#'
#' - the updated population count
#'
step_simple_growth <- function(current.population, growth.rate) {
# Calculate changes to population
new.additions <- growth.rate * current.population
# Calculate population at next timestep
next.population <- current.population + new.additions
# Return updated population
next.population
}
#' Now check that step_simple_growth() doesn't have any global variables.
library(codetools)
if (length(findGlobals(step_simple_growth, merge = FALSE)$variables) != 0) {
stop("Function step_simple_growth() may not use global variable(s): ",
findGlobals(step_simple_growth, merge = FALSE)$variables)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.