Skip to contents

verbaliseR 0.2.0

New features

Bug fixes

  • num_to_text() always returns text, as documented. Numbers 11-999 and decimals used to come back as numbers.
  • num_to_text(105, sentence_start = TRUE, uk_or_us = "US") now returns “One hundred five” rather than “One hundredfive”. The same goes for pluralise().
  • num_to_text() now handles negative numbers, following the same rules as positive numbers with “minus” in front (e.g. “minus three”, “Minus fifteen” at the start of a sentence, “-1,500”). They used to return a vector of words.
  • num_to_text() no longer prints large round numbers in scientific notation (e.g. 100000 is now “100,000” rather than “1e+05”).
  • num_to_text(1000) no longer warns that numbers greater than 1000 are kept as numerals.
  • num_to_text() gives clearer errors for infinite values, and no longer shows a “NAs introduced by coercion” warning before its own error.
  • num_to_text() reads numbers stored as factors correctly.
  • pluralise() with sentence_start = TRUE and include_number = FALSE now only capitalises the first letter (e.g. “NHS trusts” rather than “Nhs trusts”).
  • pluralise() now checks add_or_swap, which must be “add” or “swap” (any case).
  • prettify_date() options are no longer case sensitive ("uk" used to return US style, and "Informal" used to be treated as formal).
  • prettify_date() gives an error for strings that aren’t written as “YYYY-MM-DD” or “YYYY/MM/DD”, instead of returning the wrong date (e.g. “15/09/2022” used to become “20th September 0015”).
  • prettify_date() always uses English month names, whatever the locale.
  • restore_capitals() matches items literally, so items containing characters like “.”, “+” or “(” work as expected.
  • prettify_date() keeps date-times in their own time zone, so a time just after midnight no longer turns into the previous day.
  • Invalid options (e.g. uk_or_us = "Canada", sentence_start = "yes", or linking_word = c("and", "or")) now give informative errors. The options for uk_or_us, formal_or_informal and add_or_swap are now shown in the function signatures.
  • Fixed documentation typos and the pluralise() example, which used add_or_swap = TRUE.

Other changes

  • Errors and warnings now use {cli}, and have classes (e.g. verbaliseR_error_not_number, verbaliseR_warning_big_number) so they can be caught in code. {verbaliseR} now depends on {cli} and {rlang}, and no longer on {stringr}.
  • Help pages link to each other, and there is now a package help page (?verbaliseR).
  • Added tests covering the whole package, GitHub Actions for R CMD check, test coverage and a pkgdown site, and README badges.