char_replace: Replacement of non-standard characters

View source: R/char_replace.R

char_replaceR Documentation

Replacement of non-standard characters

Description

This function replaces non-standard characters (such as the German Umlaut 'ä') with their standard equivalents (in this case 'ae'). Arguments enable the user to force all characters to lower-case, trim leading and trailing whitespace characters or replace all whitespace characters and dashes with underscores or remove all whitespace characters within the string.

Usage

char_replace(
  x,
  to_lower = FALSE,
  trim = TRUE,
  rm_space = FALSE,
  rm_dash = FALSE,
  to_underscore = FALSE
)

Arguments

x

character vector, contains special characters needing to be replaced.

to_lower

logical, forces all characters to lower-case

trim

logical, if whitespaces are trimmed from the start and end. Is ignored with rm_space == TRUE.

rm_space

logical, removes all whitespace characters within the string.

rm_dash

logical, removes all dash-characters within the string.

to_underscore

logical, replaces all whitespace and dash-characters with underscores.

Value

a character vector with all non-standard characters replaced by their standard counterparts

Author(s)

Oliver Guggenbuehl

Examples

x <- "Élizàldë-González Strasse"
char_replace(x)
char_replace
char_replace(x, to_lower = TRUE, to_underscore = TRUE)
char_replace(x, to_lower = TRUE, rm_space = TRUE, rm_dash = TRUE)

STATWORX/helfRlein documentation built on Feb. 12, 2024, 2:21 a.m.