Description Usage Arguments Details Value Examples
View source: R/keyboardize_punctuation.R
Takes a dataset and, for all categories in factor variables, standardizes stylized typographic characters to ASCII versions that are easily typeable on a keyboard.
1 | keyboardize_punctuation(df, convert_characters = FALSE)
|
df |
A |
convert_characters |
Should variables of class |
Text labels in datasets occasionally contain characters not easily typeable on a standard keyboard which are almost impossible to distinguish from keyboard characters. (This often happens when pasting text in from Microsoft Word). These include the curly apostrophe, the en-dash, the em-dash and the ellipsis. This function converts these typographic characters to characters that are on keyboards by default: the single straight apostrophe, the hyphen-minus, and three periods.
A copy of the original data.frame
, with nonstandard characters replaced.
1 2 3 4 5 6 7 8 | library(dplyr)
# Create an unwanted factor label containing a stylized apostrophe ’ for illustration.
dec13_excerpt <- dec13_excerpt %>% mutate(receduc =
forcats::fct_recode(receduc,
`Don’t know/Refused` = "DK/Ref"))
table(dec13_excerpt$receduc)
dec13_excerpt <- keyboardize_punctuation(dec13_excerpt)
table(dec13_excerpt$receduc)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.