R/fix_names.R

Defines functions fix_names

Documented in fix_names

#' Fix names of provinces
#'
#' \code{fix_names} allows to correct the names of the provinces, adopting a
#' standard convention.
#'
#' Ease the integration of data from multiple sources.
#'
#' @param x a vector of characters.
#' @return A vector of characters, the corrected version of the x input.
#' @export
#' @author Marc Choisy
#' @examples
#' fix_names(c("Soc T rang", "SOn ia", "Son ia"))
fix_names <- function(x) {
  dictionary <- dictionary[dictionary$from %in% x, ]
  attach(dictionary)
  for(i in 1:nrow(dictionary)) x <- sub(from[i], to[i], x)
  detach()
  x
}
choisy/mcutils documentation built on May 29, 2019, noon