utils_text: Clean character vector

Description Usage Arguments Details Value Examples

Description

Clean a character vector (text string) by replacing punctuation and whitespaces with underscores.

Usage

1
clean_text(x, lower = F, ...)

Arguments

x

character vector

lower

logical, convert all characters to lowercase?

...

further arguments passed to other methods

Details

Useful to clean a vector of species names, perhaps obtained from a biodiversity database, to a machine-readable form.

Value

Cleaned-up character vector of the same length and with the same attributes as x.

Examples

1
2
3
4
5
6
7
8
# sloppy
x <- c('Alnus___incana', 'Alnus incana ssp.tenuifolia',
       'Alnus rubra  ', '  Alnus viridis',
       'Alnus viridis ssp. crispa', 'Alnus viridis ssp.. sinuata')
# cleaned
clean_text(x)
clean_text(x, lower=TRUE)
clean_text('Alnus viridis ssp.. sinuata ')

phytomosaic/ecole documentation built on Jan. 2, 2022, 11:24 p.m.