Learn R Programming

neatR (version 0.2.0)

nstring: neat representation of string

Description

neat representation of string

Usage

nstring(
  string,
  case = NULL,
  remove.specials = FALSE,
  whitelist.specials = "",
  en.only = FALSE
)

Value

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

Arguments

string

a string / character

case

an optional parameter to convert the string variable to specific case. By default the case of the string is kept as it is. The available case conversions are lower, upper, title, start and initcap case.

remove.specials

an optional boolean. To remove special characters including any punctuation to be removed from the string, set this to TRUE.

whitelist.specials

an optional vector of strings. If any special characters to be retained while remove.specials is set to TRUE. See examples below.

en.only

an optional parameter taking boolean values, if set to TRUE, only english alphabets (and numbers) are kept in the string. Non english characters are removed.

See Also

Refer to https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage for more information about the different cases of text/string.

Examples

Run this code
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, whitelist.specials = c('_'))

Run the code above in your browser using DataLab