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.

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.

Value

character string

Details

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

Examples

fix_case("the hba1c level was reported as a1C", case = "sentence")
#> [1] "The HbA1c level was reported as A1c"