str_sanitize: Sanitize strings by removing reserved and non portable...

View source: R/data-clean.R

str_sanitizeR Documentation

Sanitize strings by removing reserved and non portable character set

Description

Make a reasonable attempt of converting a string into a preferred standard form to name variables and file names

Usage

str_sanitize(vnames, sep = "_", no.accent = TRUE)

Arguments

vnames

character vector to be sanitized

sep

character of replacements, Default: '_'

no.accent

logical, if is to remove accents from vnames, Default: TRUE

Details

str_sanitize() removes or replace the following:

  • Control characters

  • Reserved characters

  • Unix reserved filenames (. and ..)

  • Trailing periods and spaces (invalid on Windows)

  • Windows reserved filenames (CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9)

  • any accented noum and punctuation character

  • any resulting initial or trailing underscore or multiples

  • uppercase by lowercase

  • repeated seperator

  • names starting with a number by a character

Value

a character vector in lowercase with underscore (sep) to separate nouns

Examples

str_sanitize(c("esúpido", "^ ãb ", "..c`a§", "A .xls.xls", "1° dia"))

lhmet/lhmetools documentation built on July 26, 2024, 1:48 p.m.