R/taxa.R

Defines functions taxa

Documented in taxa

#' Get taxa
#'
#' Gets the (unique) scientific names and associated taxonomic information from
#' the observations of a Camera Trap Data Package object.
#'
#' @inheritParams print.camtrapdp
#' @return [tibble::tibble()] data frame with the taxonomic information, containing at
#'   least a `scientificName` column.
#' @family accessor functions
#' @export
#' @examples
#' x <- example_dataset()
#' taxa(x)
taxa <- function(x) {
  check_camtrapdp(x)
  observations(x) %>%
    dplyr::filter(!is.na(.data$scientificName)) %>%
    dplyr::select("scientificName", dplyr::starts_with("taxon.")) %>%
    dplyr::distinct() %>%
    dplyr::rename_with(~ sub("^taxon.", "", .x))
}

Try the camtrapdp package in your browser

Any scripts or data that you put into this service are public.

camtrapdp documentation built on Sept. 11, 2024, 9:03 p.m.