Skip to contents

plural_phrasing() returns a list object describing the value to use when display when x - y is 1 (single) or not one (multiple or fraction). This helps write "1 person" vs "2 people"

Usage

plural_phrasing(single, multi)

Arguments

single

string to use when delta = 1

multi

string to use when delta > 1

Value

Returns a list object.

Details

plural_phrasing() will primarily be used in headline() and passed along to compare_conditions(). Similar to trend_terms(). Plural phrases can be passed in a list. See examples below.

Examples

plural_phrasing(single = "person", multi = "people")
#> $single
#> [1] "person"
#> 
#> $multi
#> [1] "people"
#> 

headline(
  x = 1:2,
  y = 0,
  headline = "a difference of {delta} {people}",
  plural_phrases = list(people = plural_phrasing("person", "people"))
)
#> a difference of 1 person
#> a difference of 2 people


# a complex example passing multiple trends and plural phrases
headline(
  35, 30,
  headline =
    "We had {an_increase} of {delta} {people}.
    That is {delta} {more} {employees} \\
    than the same time last year ({orig_values}).",
  trend_phrases = list(
    an_increase = trend_terms("an increase", "a decrease"),
    more = trend_terms("more", "less")
  ),
  plural_phrases =
    list(
      people = plural_phrasing("person", "people"),
      employees = plural_phrasing("employee", "employees")
    )
)
#> We had an increase of 5 people.
#> That is 5 more employees than the same time last year (35 vs. 30).