Returns the appropriate singular or plural form of a word based on the
provided count n
.
Usage
check_singular_plural(n, singular = "", plural = "s")
Arguments
- n
Numeric value representing the count. Must be a single integer.
- singular
Character string representing the singular form of the word.
Defaults to an empty string.
- plural
Character string representing the plural form of the word.
Defaults to s
.
Value
A character string: singular
if n
is 1
,
or plural
if n
is greater than 1
.
Examples
check_singular_plural(1, "apple", "apples")
#> [1] "apple"
check_singular_plural(2, "apple", "apples")
#> [1] "apples"
check_singular_plural(0, "apple", "apples")
#> [1] "apple"
check_singular_plural(1)
#> [1] ""
check_singular_plural(2)
#> [1] "s"