Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

alphaOnly

Keep only alpha-numeric symbols


Description

From a text string, keep ASCII letters, numbers, as well as "'", " ", "_" "(", ")", "-", and "+". For maximum compatability with the cross-platform file-naming standard. Obliterates all characters that migth be mistaken for shell symbols, like "\^", "\$", "\@" and so forth.

Usage

alphaOnly(x, also)

Arguments

x

text string, or vector of strings (each of which is processed separately)

also

A named vector of other symbols that the user wants to remove, along with replacements. For example, c(" " = "_", "-" = "", "+" = "") to replace space with underscore and minus and plus signs with nothing.

Details

Removes trailing spaces.

This version allows internal spaces in the string, by default. The also argument can be used to eliminate spaces or other hated symbols.

Value

cleaned text string

Author(s)

Paul Johnson <pauljohn@ku.edu>

Examples

x <- c("[]kansas(city) Missouri", "percent%slash/",
       "\back{squiggle}_under(paren)", "*star-minus+plus")
alphaOnly(x)
alphaOnly(x, also = c(" " = "_", "+" = "_"))
alphaOnly(x, also = c("(" = "[", ")" = "]"))

kutils

Project Management Tools

v1.70
GPL-2
Authors
Paul Johnson [aut, cre], Benjamin Kite [aut], Charles Redmon [aut], Jared Harpole [ctb], Kenna Whitley [ctb], Po-Yi Chen [ctb], Shadi Pirhosseinloo [ctb]
Initial release
2020-04-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.