fix_case: Fix word case

View source: R/fix_case.R

fix_caseR Documentation

Fix word case

Description

Attempt to convert words from given format to sentence, title, lower, or upper case while being mindful of APA style guidelines, acronyms, and custom word replacement lists.

Usage

fix_case(
  x,
  to_lower_first = FALSE,
  replace_underscores = TRUE,
  underscore_replacement = " ",
  to_lower_minor_words = TRUE,
  minor_words = curios::minor_words,
  to_upper_known_acronyms = TRUE,
  known_acronyms = curios::known_acronyms,
  replace_named_words = FALSE,
  named_words = NA,
  case = c("title", "sentence", "lower", "upper")
)

Arguments

x

character string.

to_lower_first

logical,indicating character string should first be converted to all lower case.

replace_underscores

logical determines replacement of underscore characters.

underscore_replacement

character string to replace underscores.

to_lower_minor_words

logical determines if minor words are all lower case.

minor_words

named character vector of minor words that will be converted to lower case.

to_upper_known_acronyms

logical determines if known acronyms are replaced with case correct versions.

known_acronyms

named character vector of acronyms that will be converted to proper case.

replace_named_words

logical determines if a set of named_words are replaced with case correct versions.

named_words

named character vector of words that will be replaced with alternate words or word case

case

character designating the overall case structure: title (default), sentence, lower, upper.

Details

Note: word replacement is done in a case sensitive manner. For example, "usDA" would be replaced with "USDA" as would "UsDA" or "usda".

Value

character string

Examples

fix_case("the hba1c level was reported as a1C", case = "sentence")

johnaclouse/curios documentation built on June 14, 2022, 6:45 a.m.