alphaOnly {kutils} | R Documentation |
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("(" = "[", ")" = "]"))