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 inperiod
or the columndate
(to compute the period column), plus the column specified inby
.- 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"
.
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_topic_segmentation()
,
plot_topic_share_per_period()
Examples
rdb::rfrnds(quiet = TRUE,
max_cache_age = "1 year") |>
rdb::plot_rfrnd_share_per_period(by = "level")