Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

collapse_pop_state

Extract threshold based population size information


Description

Given a model object, this function computes population sizes given thresholds for a state variable of interest. For example, the number (or proportion) of individuals shorter than 60 cm tall at the 20th time step of the model.

Usage

collapse_pop_state(ipm, time_step, ...)

Arguments

ipm

An object created by make_ipm

time_step

the time step to pull out. Can be a single time step or a vector of multiple time steps. In the latter case, one value is computed for each time step.

...

Named expressions that provide the threshold information for the desired classes. The expression should be logicals with a state variable name on the left side, and a threshold value on the right side.

Value

A named list of numeric vectors containing the summed population sizes at each requested time step. Names are taken from ....

Examples

data(gen_di_det_ex)

# Rebuild the model and return_main_env this time

gen_di_det_ex <- gen_di_det_ex$proto_ipm %>%
  make_ipm(iterate = TRUE, iterations = 50, return_main_env = TRUE)

disc_sizes <- collapse_pop_state(gen_di_det_ex,
                                 time_step = 20:25,
                                 seedlings = ht <= 10,
                                 NRA = ht > 10 & ht <= 200,
                                 RA = ht > 200)

# time series for this model. This extracts the first 20 iterations
# (excluding the initial population state) and collapses them according
# to the rules we pass to ...


 time_series <- collapse_pop_state(gen_di_det_ex,
                                   time_step = 2:21,
                                   seedlings = ht <= 10,
                                   NRA = ht > 10 & ht <= 200,
                                   RA = ht > 200)

ipmr

Fits Integral Projection Models Using an Expression Based Framework

v0.0.1
MIT + file LICENSE
Authors
Sam Levin [aut, cre] (<https://orcid.org/0000-0002-3289-9925>), Aldo Compagnoni [aut], Dylan Childs [aut], Sanne Evers [aut], Roberto Salguero-Gomez [aut], Tiffany Knight [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.