trim_taxa: Trim taxa

View source: R/trim_taxa.R

trim_taxaR Documentation

Trim taxa

Description

Trim excess text from taxa names. Doing this before querying a taxonomic authority improves matching.

Usage

trim_taxa(x = NULL, path = NULL)

Arguments

x

(character) A list of taxa names

path

(character) The path to the directory containing taxa_map.csv

Details

Characters trimmed by this function:

  • White spaces (trailing and leading)

  • Species abbreviations following a genus value (e.g. "Sp.", "Spp.", "Cf.", "Cf...", etc.)

Value

  • If using x, then an updated list of taxa is returned.

  • If using path, then an updated version of taxa_map.csv is written to file and returned as a data frame.

Examples

# Input a list of names

my_taxa <- c("Koeleria_cristata", "Cyperus sp.", "Poa Cf.   ")
my_taxa <- trim_taxa(x = my_taxa)
my_taxa

# Input taxa_map.csv

data <- data.table::fread(system.file("example_data.txt", package = 'taxonomyCleanr'))
my_path <- tempdir()
tm <- create_taxa_map(path = my_path, x = data, col = "Species")
tm <- trim_taxa(path = my_path)
tm


EDIorg/taxonomyCleanr documentation built on April 9, 2023, 2:43 a.m.