Skip to contents

Creates a Plotly stacked area chart that visualizes the share of referendums per period, grouped by another column.

Usage

plot_rfrnd_share_per_period(
  data,
  by,
  period = c("week", "month", "quarter", "year", "decade", "century")
)

Arguments

data

RDB referendum data as returned by rfrnds(). A data frame that at minimum contains the column specified in period or the column date (to compute the period column), plus the column specified in by.

by

data column to group by before counting number of referendums. Tidy selections are supported.

period

Type of period to count referendums by. One of "week", "month", "quarter", "year", "decade" or "century".

Value

A plotly object.

Details

Note that the period types "year", "decade" and "century" are unique timespans, while "week", "month" and "quarter" are recurring timespans (e.g. every year has a week 1).

See also

Examples

rdb::rfrnds(quiet = TRUE,
            max_cache_age = "1 year") |>
  rdb::plot_rfrnd_share_per_period(by = "level")