This function calculates the population diet using two different approaches: the “sum” or the “average” method.

1 | ```
pop.diet(dataset, prop = "sum")
``` |

`dataset` |
Object of class RInSp with data. |

`prop` |
Option specifying the type of calculation. Two types: “sum” or “average”. |

The “sum” approach is the most straightforward. One sums up all resource counts within a category across all individuals to get the population's use, then determine the proportion of each resource category in the population's repertoire. The proportion *q_j* of the resource j in the population's diet is:

*q_j = \frac{∑_i{n_{ij}}}{∑_{ji}{n_{ij}}}*

The drawback of this approach is that individuals that eat large numbers of items, or larger total mass of items, will bias the population to look more like them.

The “average” method (average proportion) circumvents this problem by first converting individual diets into proportions *p_{ik}*, then averaging these proportions for each resource k.

Along with the population's diet the procedure calculates the Levins' D index (Levins 1968) of diversity as:

* D = 1 - \frac{1}{∑{q_{j}^2}}*

Returns a list of information:

`popdiet` |
Vector of the specified population diet. |

`popdtype` |
The type of population diet. |

`richness` |
The richness of resources (for now it has sense only for integer data type). |

`D` |
The Levins' D index for resources. |

Dr. Nicola ZACCARELLI

Bolnick, D.I., L.H. Yang, J.A. Fordyce, J.M. Davis, and Svanback, R. 2002. Measuring individual-level resource specialization. *Ecology* **83**: 2936-2941.

Levins R. 1968. *Evolution in Changing Environments: Some Theoretical Explorations*. Princeton Univ. Press.

Function `Null.Hp.RInSp`

.

1 2 3 4 5 6 | ```
data(Stickleback)
# Select a single spatial sampling site (site D)
GutContents_SiteD = import.RInSp(Stickleback, row.names = 1, info.cols = c(2:13),
subset.rows = c("Site", "D"))
PopDiet = pop.diet(GutContents_SiteD, prop = "average")
rm(list=ls(all=TRUE))
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.