Hdash: Calculates H' the Shannon diversity index

View source: R/Hdash.R

HdashR Documentation

Calculates H' the Shannon diversity index

Description

Hdash() matches a list of species counts with the AMBI species list and calculates H' the Shannon diversity index. (Shannon, 1948)

Usage

Hdash(
  df,
  by = NULL,
  var_species = "species",
  var_count = "count",
  check_species = TRUE,
  df_species = NULL
)

Arguments

df

a dataframe of species observations

by

a vector of column names found in df by which calculations should be grouped e.g. c("station","date")

var_species

name of the column in df containing species names

var_count

name of the column in df containing count/density/abundance

check_species

boolean, default = TRUE. If TRUE, then only species found in the species list are included in H' index. By default, the AZTI species list is used.

df_species

optional dataframe with user-specified species list.

Details

If the function is called with the argument check_species = TRUE then only species which are successfully matched with the specified species list are included in the calculations. This is the default. If the function is called with check_species = FALSEthen all rows are counted.

Value

a list of two dataframes:

  • H : results of the AMBI index calculations. For each unique combination of byvariables the following values are calculated:

    • H : the Shannon diversity Index, H'

    • S : the number of species

    • N : the number of individuals

  • match : the original dataframe with columns added from the species list. For a user-specified list provided df_species, all columns will be included. If the user-specified species list contains only a single column with species names, then a new column match will be created, with a value of 1 indicating a match and an NA value where no match was found.

For the default AZTI species list the following additional columns will be included:

  • group : showing the AMBI species group

  • RA : indicating that the species is reallocatable according to the AZTI list. That is, it could be re-assigned to a different species group.

References

Shannon, C. E. (1948) "A mathematical theory of communication," in The Bell System Technical Journal, vol. 27, no. 3, pp. 379-423. \Sexpr[results=rd]{tools:::Rd_expr_doi("doi:10.1002/j.1538-7305.1948.tb01338.x")}

Examples


Hdash(test_data, by=c("station"))


ambiR documentation built on Dec. 20, 2025, 1:06 a.m.