R/spelling.R

Defines functions spelling

Documented in spelling

#' Correct Spelling
#'
#' @description Functions for correcting common fishery and biological spelling errors.
#'
#' @param x Character string(s).
#'
#' @examples
#' spelling("aligatore")
#' spelling("yelow  tail")

#' @export
spelling <- function(x){
   # Load spelling table:
   tab <- utils::read.table(locate(package = "gulf.utils", file = "spelling.txt"), header = TRUE, sep = "\t", stringsAsFactors = FALSE)

   # Perform corrections:
   for (i in 1:nrow(tab)) x <- gsub(tab$expression[i], tab$correction[i], x)

   return(x)
}
TobieSurette/gulf.utils documentation built on Dec. 1, 2024, 6:01 a.m.