Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/aveytoolkit_ProcessNames.R
Cleans up strings to make them pretty names by removing punctuation, whitespace, and specified substrings
1 | ProcessNames(strs, stringsToRm = NULL, rmPunct = TRUE, sep = "_")
|
strs |
vector or strings to process |
stringsToRm |
a vector or list of strings to search for and remove from strs |
rmPunct |
should punctuation be removed? Default is TRUE. |
sep |
character to replace whitespace |
stringsToRm are replaced by ” in the order they are given using gsub. After this, punctuation is removed if rmPunct is TRUE. Then, leading and/or trailing whitespace will be removed and the sep will be used to separate words. This function is useful when reading in other people's data and you want to change the row or column names to legal R names or just shorten the names.
a vector of modified strings from strs
Stefan Avey
1 2 3 4 5 6 7 | badNames <- c("Who's Birthday?", "[Date]", "gift Received")
## Remove the string "Who's", remove punctuation, and separate words by '_'
goodNames <- ProcessNames(badNames,stringsToRm="Who's", rmPunct=TRUE, sep='_')
goodNames
## Remove the string "Who's", don't remove punctuation, and put no separation between words
goodNames <- ProcessNames(badNames,stringsToRm="Who's", rmPunct=FALSE, sep='')
goodNames
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.