Skip to content

Instantly share code, notes, and snippets.

View eric-pedersen's full-sized avatar

Eric Pedersen eric-pedersen

View GitHub Profile
@eric-pedersen
eric-pedersen / dplyr_simulations.R
Last active March 13, 2024 09:04
Shows how to simulate ecological time series using the purrr accumulate functions and dplyr.
# This example shows how to use purrr to simulate ecological values. The
# accumulate function in purrr can be quite flexible as it can take lists as
# entries, and pass extra parameters on to the function. The key feature
# to allow for time-varying parameters here is that the input for the function
# has to include both the present state of the population(s), but also a time
# index, so the function knows what values of the parameters to refer to.
library(dplyr)
library(purrr)
library(ggplot2)