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 columntopics_tier_#of the specifiedtier.- tier
Tier of the topics variable to plot.
1L,2Lor3L.- 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 sametier, every topic is counted 1/n.
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
Other visualization functions:
ggplot_streamgraph(),
plot_rfrnd_share_per_period(),
plot_topic_segmentation()
Examples
rdb::rfrnds(quiet = TRUE) |>
rdb::plot_topic_share_per_period(period = "decade")