Format text for label printing
Arguments
- x
Character: Input
- underscores_to_spaces
Logical: If TRUE, convert underscores to spaces.
- dotsToSpaces
Logical: If TRUE, convert dots to spaces.
- toLower
Logical: If TRUE, convert to lowercase (precedes
toTitleCase). Default = FALSE (Good for getting all-caps words converted to title case, bad for abbreviations you want to keep all-caps)- toTitleCase
Logical: If TRUE, convert to Title Case. Default = TRUE (This does not change all-caps words, set
toLowerto TRUE if desired)- capitalize_strings
Character, vector: Always capitalize these strings, if present. Default =
"id"- stringsToSpaces
Character, vector: Replace these strings with spaces. Escape as needed for
gsub. Default ="\\$", which formats common input of the typedata.frame$variable
Examples
x <- c("county_name", "total.cost$", "age", "weight.kg")
labelify(x)
#> [1] "County Name" "Total Cost" "Age" "Weight Kg"