Closed zachary-foster closed 6 years ago
#' Remove the redundant taxon names #' #' Remove the names of parent taxa in the begining of their children's names in a \code{classified} object. #' This is useful for remove genus names in species binomials. #' #' @param obj a \code{taxmap} object #' #' @return \code{character} #' #' @export remove_redundant_names <- function(obj) { new_names <- vapply(supertaxa(obj, recursive = FALSE, include_input = TRUE), function(x) gsub(obj$taxon_names()[x[1]], pattern = paste0("^", obj$taxon_names()[x[2]], "[_ ]+"), replacement = ""), character(1)) lapply(seq_along(new_names), function(i) { obj$taxa[[i]]$name$name <- new_names[i] }) return(obj) }
added to taxa instaead
taxa