Pluralise words if their accompanying number is not 1
Arguments
- word
A word which should be returned as plural if
countis not equal to 1.- count
A number to apply to
word. Can be a vector (e.g. a column indplyr::mutate()), in which casewordandpluralcan either be single words or vectors of the same length ascount. Missing counts return missing values.- plural
How to make the plural; defaults to an "s" which is added at the end of the word. Can be anything. See
add_or_swap.- add_or_swap
Choose between
add(add the plural form (e.g. "s") onto the end; e.g.housebecomeshouses) andswap(swap for the plural form; e.g.mousebecomesmice)- include_number
Logical. If
TRUE, the number will be turned into text, as pernum_to_text(), usingzero_or_no,uk_or_usandbig_mark.- sentence_start
Logical. Defaults to
FALSE, which results in only numbers 0-10 being written out in full. IfTRUE, numbers 11-1000 are written out in full if included. (Ifinclude_numberisFALSE, the first letter ofwordis capitalised, and the rest of the word is left as is.)- zero_or_no
Specify what to print when the number is 0. Defaults to "no". Can be any string.
- uk_or_us
Defaults to UK which adds an "and" between "hundred" and other numbers (e.g. "One hundred and five"). If "US" is chosen, the "and" is removed (e.g. "One hundred five").
- big_mark
Defaults to "," (e.g. "1,999").
Value
A word which is pluralised or not based on the value of count, or
a character vector the same length as the longest of word, count and
plural
See also
Other verbaliseR functions:
listify(),
num_to_text(),
prettify_date(),
restore_capitals()
Examples
pluralise("penguin", 3)
#> [1] "three penguins"
pluralise("bateau", 1234, "x")
#> Warning: Numbers greater than 1000 are returned as numerals, regardless of their place
#> in the sentence.
#> [1] "1,234 bateaux"
pluralise("sheep", 333, "sheep", add_or_swap = "swap", sentence_start = TRUE)
#> [1] "Three hundred and thirty-three sheep"
pluralise(c("penguin", "seal"), c(1, 3))
#> [1] "one penguin" "three seals"
