-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
15 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,17 @@ | ||
#' Get species | ||
#' | ||
#' Gets all identified species. | ||
#' @description | ||
#' `r lifecycle::badge("deprecated")` | ||
#' | ||
#' This function is deprecated. Please use [taxa()] instead. | ||
#' | ||
#' @param x Camera trap data package object, as returned by | ||
#' [camtrapdp::read_camtrapdp()]. | ||
#' @return A tibble data frame with all scientific names and vernacular names of | ||
#' the identified species. | ||
#' @family exploration functions | ||
#' @inheritParams taxa | ||
#' @export | ||
#' @examples | ||
#' x <- example_dataset() | ||
#' get_species(x) | ||
get_species <- function(x) { | ||
# Get taxonomic information from metadata | ||
if (!"taxonomic" %in% names(x)) { | ||
return(NULL) | ||
} else { | ||
taxonomy <- x$taxonomic | ||
if ("vernacularNames" %in% names(taxonomy[[1]])) { | ||
# Get all languages used in vernacularNames | ||
langs <- purrr::map(taxonomy, function(x) { | ||
vernacular_languages <- NULL | ||
if ("vernacularNames" %in% names(x)) { | ||
vernacular_languages <- names(x$vernacularNames) | ||
} | ||
}) | ||
langs <- unique(unlist(langs)) | ||
|
||
# Fill empty vernacular names with NA | ||
taxonomy <- purrr::map(taxonomy, function(x) { | ||
missing_langs <- langs[!langs %in% names(x$vernacularNames)] | ||
for (i in missing_langs) { | ||
x$vernacularNames[[i]] <- NA_character_ | ||
} | ||
x | ||
}) | ||
} | ||
# flatten list and transform to data.frame | ||
purrr::map_dfr(taxonomy, function(x) { | ||
purrr::list_flatten(x, name_spec = "{outer}.{inner}") | ||
} | ||
) | ||
} | ||
lifecycle::deprecate_warn( | ||
when = "1.0.0", | ||
what = "get_species()", | ||
with = "taxa()" | ||
) | ||
taxa(x) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.