R/trim.R

Defines functions trim

Documented in trim

#' Trim a name and remove duplicate tabs and whitespaces
#' 
#' Remove duplicate and misplaced whitespace characters
#' 
#' @param taxon a character vector with a single taxon name
#' @export
#' @return a character vector
#' @examples
#' \dontrun{
#' trim("   Myrcia  lingua")
#' }
trim <- function(taxon) {
  taxon <- gsub("\\t", " ", taxon)
  taxon <- gsub("\\s+", " ", taxon)
  taxon <- gsub("^\\s+", "", taxon)
  taxon <- gsub("\\s+$", "", taxon)
  return(taxon)
}

Try the flora package in your browser

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

flora documentation built on April 28, 2020, 9:05 a.m.