nstring: neat representation of string

View source: R/strings.R

nstringR Documentation

neat representation of string

Description

neat representation of string

Usage

nstring(
  text,
  case = NULL,
  remove_specials = FALSE,
  keep_chars = "",
  ascii_only = FALSE,
  string = NULL,
  whitelist_specials = NULL,
  en_only = NULL
)

Arguments

text

a string / character

case

a string, It specifies how the string should be formatted. Current options are 'lower', 'upper', 'title', 'start' and 'initcap'.

remove_specials

a Boolean. If TRUE, special characters are removed from the string.

keep_chars

a vector of characters that are kept even if remove_specials is TRUE.

ascii_only

a Boolean. If TRUE, only ASCII characters are kept.

string

Deprecated. Use 'text' instead.

whitelist_specials

Deprecated. Use 'keep_chars' instead.

en_only

Deprecated. Use 'ascii_only' instead.

Value

White space cleaned and optionally formatted by case conversion and removal of special characters of the input string.

Examples

nstring("   All MOdels are wrong.   some ARE useful!!! ",
  case = "title",
  remove_specials = TRUE
)
nstring("all Models are Wrong some are Useful",
  case = "start",
  remove_specials = TRUE
)
nstring("variable_123!!", remove_specials = TRUE, keep_chars = c("_"))

neatR documentation built on Jan. 31, 2026, 5:07 p.m.