knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

There are a number of built-in functions in the grainchanger package, with their usage outlined below. While it is possible to use user-defined functions within winmove_agg, nomove_agg, and winmove, we welcome suggestions for additional functions. Please add as an issue - doing it this way means we can maximise the speed of the function.

All functions can also be used on their own, either on an object of class winmove or numeric.

When functions are used within winmove_agg, winmove, or directly on an object of class winmove, they are calculated relative to within a moving window.

When functions are used within nomove_agg all cells of fine_dat within a given cell of coarse_dat are aggregated using the function.

Current functions

function_overview <- data.frame(
  `Function Name` = c("prop", "shdi", "shei", "var_range"),
  `Description` = c("Calculate the proportion of a given class", 
                    "Calculate the Shannon diversity", 
                    "Calculate the Shannon evenness", 
                    "Calculate the size of the range of values"),
  `Additional arguments` = c("lc_class (numeric)", 
                             "lc_class (numeric)",
                             "lc_class (numeric)",
                             "")
)

knitr::kable(function_overview)

Shannon diversity and evenness

Shannon diversity is calculated as $$SHDI = -\sum_{i = 1}^m p_i lnp_i$$ where $p_i$ is the proportion of a given class $i$ of a total $m$ classes.

Shannon evenness is calculated as $$SHEI = \frac{S}{ln(m)}$$

Additional functions

We plan to add other useful functions to this small set of built-in functions, such as relevant metrics from FRAGSTATS.

We also welcome suggestions for additional functions. Please add as an issue - doing it this way means we can maximise the speed of the function.



laurajanegraham/winmoveR documentation built on June 4, 2023, 3:15 p.m.