You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
headliner::headline(1, 2) +headliner::headline(3,4)
# decrease of 1 (1 vs. 2) decrease of 1 (3 vs. 4)
Multiple trend_terms() and plural_phrasing()
headline(
35, 30,
headline="We had {article_trend[1]} {trend[1]} of {delta} {people[1]}. That is {delta} {trend[2]} {people[2]} \\ than the same time last year ({orig_values}).",
trend_phrases=
trend_terms(
more= c("increase", "more"),
less= c("decrease", "less")
),
plural_phrases=list(
people= plural_phrasing(
single= c("person", "employee"),
multi= c("people", "employees")
)
)
)
#> We had an increase of 5 people.#> That is 5 more employees than the same time last year (35 vs. 30).
Create list of headlines
headline_counts<-function(...) {
headline(
...,
headline="{delta} {trend} {people}",
trend_phrases= trend_terms("more", "less"),
plural_phrases=list(people= plural_phrasing("person", "people"))
)
}
headline_percents<-function(...) {
headline(
...,
headline="{delta_p}% {trend}",
trend_phrases= trend_terms("higher", "lower")
)
}
headline(30, 40)
# decrease of 10 (30 vs. 40)
headline_counts(30, 40)
# 10 less people
headline_percents(30, 40)
# 25% lowerheadline_types<-list(
simple=headline,
n=headline_counts,
pct=headline_percents
)
make_headlines<-function(compare, reference, headline_methods) {
map(
.x=headline_methods,
.f=~(.x(compare, reference))
)
}
headline_employees<- make_headlines(30, 35, headline_types)
headline_employees$simple# decrease of 5 (30 vs. 35)headline_employees$n# 5 less people headline_employees$pct# 14.3% lower
Capitalize words
headline(
x=12,
y=8,
headline="{cap(art( trend ))} of {delta_p}%",
cap=stringr::str_to_sentence,
art=add_article
)
# "An increase of 50%"
The text was updated successfully, but these errors were encountered:
Add headlines together (give credit to
glue
)Multiple
trend_terms()
andplural_phrasing()
Create list of headlines
Capitalize words
The text was updated successfully, but these errors were encountered: