# Implementing the mathematical formula for rarefaction to measure richness in R (CC197)

Did you know that there’s a mathematical formula to measure richness by rarefaction? It leverages all sorts of concepts that we rarely think about, but are important to appreciate to full understand rarefaction. In this episode we’ll use the R factorial, combn, choose, and lchoose functions to get an exact solution for the richness of a community rarefied to a specific sampling depth. Along the way we’ll also discuss the power of working with logrithms. I’ll show how to synthesize and visualize the data using tools from base R, dplyr, ggplot2 and other tidyverse packages.

## Code

You can browse the state of the repository at the