R/rgb_country_codes.r

Defines functions rgb_country_codes

Documented in rgb_country_codes

#' Look up 2 character ISO country codes
#'
#' @param country_name Name of country to look up
#' @param fuzzy If TRUE, uses agrep to do fuzzy search on names.
#' @param ... Further arguments passed on to agrep or grep
#' @export
#' @examples
#' \dontrun{
#' rgb_country_codes(country_name="United")
#' }
rgb_country_codes <- function(country_name, fuzzy = FALSE, ...) {
  x <- enumeration_country()
  if (fuzzy) {
    x[agrep(country_name, x$title, ...),]
  } else {
    x[grep(country_name, x$title, ...),]
  }
}
ropensci/rgbif documentation built on April 20, 2024, 10:49 a.m.