Skip to contents

Creates a Plotly stacked area chart that visualizes the share of referendum topic occurences per period.

Usage

plot_topic_share_per_period(
  data,
  tier = 1L,
  period = c("week", "month", "quarter", "year", "decade", "century"),
  weight_by_n_rfrnds = TRUE
)

Arguments

data

RDB referendum data as returned by rfrnds(). A data frame that at minimum contains the column topics_tier_# of the specified tier.

tier

Tier of the topics variable to plot. 1L, 2L or 3L.

period

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

weight_by_n_rfrnds

Whether or not to weight topic occurences by number of referendums. If TRUE, for a referendum with n different topics of the same tier, every topic is counted 1/n.

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) |>
  rdb::plot_topic_share_per_period(period = "decade")