make_sparklines: Function that takes a dataframe and returns a list of line...

View source: R/make_sparklines.R

make_sparklinesR Documentation

Function that takes a dataframe and returns a list of line charts

Description

One line chart is returned for each level in the grouping variable. These line charts are intended for use as sparklines in tables.

Usage

make_sparklines(df, group_var, date_var = date, value_var = value)

Arguments

df

Dataframe containing data to summarise in sparkline form

group_var

Unquoted name of grouping variable in df. One line chart will be created for each unique value in group_var.

date_var

Unquoted name of date variable in df to plot on the x-axis in the line charts. Default is date.

value_var

Unquoted name of variable in df to map to the y aesthetic of the line charts. Default is value.

Details

All line charts in the list will have the same maximum and minimum dates on the x-axis, defined by the range in the date_var in df.

Value

A list of line charts ({ggplot2} objects).

Examples

make_sparklines(df = ggplot2::economics_long, group_var = variable)

djpr-data/djprlabourdash documentation built on April 28, 2023, 6:16 p.m.