R/find_cod.R

Defines functions find_cod

Documented in find_cod

#' @title Find state or municipality information
#' @param query name of city/state, is a character
#' @examples
#' find_cod("rio de janeiro")
#' find_cod("bahia")
#' @return \code{tibble}
#' @importFrom dplyr filter
#' @importFrom stringr str_detect
#' @importFrom rlang is_character abort
#' @export

find_cod <- function(query) {
  if (!rlang::is_character(query)) {
    rlang::abort("Argument `query` must be a character")
  }

  siconfir::br_cods %>%
    dplyr::filter(stringr::str_detect(ente, query))
}

Try the siconfir package in your browser

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

siconfir documentation built on Jan. 15, 2023, 5:09 p.m.