R/diversity_functions1.R

Defines functions species_richness_1

Documented in species_richness_1

#' Species Richness
#'
#' A function to calculate the Species Richness of a population passed to the function, and return this
#' value as a single integer.
#'
#' @param population - a vector of species counts
#'
#' @return species.richness
#' @export species.richness - a count of the number of species present in "population"
#'
#' @examples
species_richness_1  <- function(population) {
  # find all the species which are present in the population
  species.presence <- population > 0
  # calculate the species richness (the total number of species present in the population)
  species.richness <- sum(species.presence)
  print(species.richness)
}
EdieBishop/ProgInRBCIfunc documentation built on Dec. 23, 2019, 10:16 p.m.