View source: R/cleanifyString.r
| cleanifyString | R Documentation |
Removes special characters from a character string. Also applicable to factor variables and data.frames.
cleanifyString(x, removeNonAlphaNum = TRUE, replaceSpecialChars = TRUE,
oldEncoding = NULL, ...)
x |
a character variable, factor variable or |
removeNonAlphaNum |
logical. If |
replaceSpecialChars |
logical. If |
oldEncoding |
character. The encoding of the input data if it should be transformed to |
... |
further arguments passed to other methods. |
If unwanted characters are removed from a character string in a factor variable, this can lead
to a change in the factor structure (according to the reference category, for example). cleanifyString
restores the factor structure after removing special characters. Function is mainly used internally in the
eatRep, eatGADS, and eatModel packages.
a character variable, factor variable or data.frame with removed special characters
fac1 <- factor(c("Tablet-Paper", "Computer.(Laptop)", "Computer.(Laptop)"),
levels = c("Tablet-Paper", "Computer.(Laptop)"))
table(fac1)
# Remove special characters
fac2 <- cleanifyString(fac1)
fac2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.