Compose Sentences to Describe Comparisons

Create dynamic, data-driven text. Given two values, a list of talking points is generated and can be combined using string interpolation. Based on the 'glue' package.


headliner

CRAN_Status_Badge Downloads codecov R-CMD-check

The goal of headliner is to translate facts into insights. Given two values, headliner generates building blocks for creating dynamic text. These talking points can be combined using using glue syntax to add informative titles to plots, section headers or other text in a report.

Installation

You can install the dev version of headliner from github with:

devtools::install_github("rjake/headliner")

Let’s look at some of the talking points for the difference between 5 and 7:

library(headliner)

compare_values(5, 7) |> # returns a list
  view_list() # show as a data frame
#>                        value
#> x                          5
#> y                          7
#> delta                      2
#> delta_p                 28.6
#> article_delta            a 2
#> article_delta_p       a 28.6
#> raw_delta                 -2
#> raw_delta_p            -28.6
#> article_raw_delta       a -2
#> article_raw_delta_p  a -28.6
#> sign                      -1
#> orig_values          5 vs. 7
#> trend               decrease

We can string the talking points together like this:

headline(
  x = 5, 
  y = 7, 
  headline = "There was {article_delta_p}% {trend} ({orig_values})"
)
#> There was a 28.6% decrease (5 vs. 7)

See here for a longer introduction.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("headliner")

0.0.3 by Jake Riley, 4 years ago


https://rjake.github.io/headliner/, https://github.com/rjake/headliner/


Report a bug at https://github.com/rjake/headliner/issues/


Browse source code at https://github.com/cran/headliner


Authors: Jake Riley [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports dplyr, glue, lubridate, purrr, rlang, tibble, tidyr

Suggests ggplot2, knitr, nycflights13, rmarkdown, testthat


See at CRAN