#' Provides the cities and code for a country
#'
#' @param name A string. A portion of the name of the country searched for
#' @return A tibble displaying relevant entries for this country.
#' @examples
#' ep_search_country("austria")
#'
#' @export
#'
#' @importFrom stringr str_detect
#' @importFrom dplyr filter
#' @importFrom rlang .data
ep_search_country <- function(name) {
if (!is.character(name) | length(name) > 1) {stop("name should be a string")}
exact_match <- europollution::countries_cities %>%
dplyr::filter(stringr::str_detect(tolower(.data$countries), name))
if (nrow(exact_match) == 0) {stop(paste(name, "does not appear in the list of countries"))}
return(exact_match)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.