Skip to contents

Get species count from a dataframe

Usage

get_nspecies(df, spp_col, obstype_col = NULL, keep_NA = FALSE)

Arguments

df

a dataframe

spp_col

name of the species column from the dataframe

obstype_col

name of the observation type column from the dataframe

keep_NA

count NAs in the species length?

Value

The number of species. If obstype_col is provided, will ignore all species with obstype_col value different from animal. If keep_NA, will count NA in the total species count.

Examples

df <- data.frame(obstype = c("animal", "animal", "animal", "animal", "blank"),
                 species = c("cat", "cat", "cow", "dog", NA))
get_nspecies(df, spp_col = "species", obstype_col = "obstype")
#> [1] 3