Creates a Plotly sunburst chart that visualizes the hierarchical segmentation of referendum topic occurences.
Usage
plot_topic_segmentation(
data,
method = c("per_rfrnd", "per_topic_lineage", "naive")
)
Arguments
- data
RDB referendum data as returned by
rfrnds()
. A data frame that at minimum contains the columnstopics_tier_1
,topics_tier_2
andtopics_tier_3
.- method
Applied method to count the number of topic occurences. One of
"per_rfrnd"
: All referendums have the same weight. For a referendum with n different topics of the same tier, every topic is counted 1/n."per_topic_lineage"
: All topic lineages have the same weight. For a referendum with n different topics of the same tier, every topic is fully counted, meaning that e.g. a referendum with three different tier-3 topics has a tripled impact on the result compared to a referendum that only has a single one. Noticeably faster than"per_rfrnd"
."naive"
: Naive procedure which doesn't properly reflect topic proportions on tier 2 and 3. Based on the (wrong) assumptions that a) all referendums have the same number of topic lineages assigned and b) topics are not deduplicated per tier. By far the fastest method, though.
Details
A topic lineage is the hierarchical compound of a topic_tier_1
and optionally a grandchild topic_tier_3
and/or a child topic_tier_2
.
Note that topics can be assigned on any tier to referendums (i.e. in one case, a topic_tier_1
plus a child topic_tier_2
is assigned, and in another case
only a topic_tier_1
without any further child topic).
Furthermore, it should be noted that not every topic_tier_2
has potential child topic_tier_3
s. See the full topic hierarchy
for details.
See also
Other visualization functions:
ggplot_streamgraph()
,
plot_rfrnd_share_per_period()
,
plot_topic_share_per_period()
Examples
# count each referendum equally
rdb::rfrnds(quiet = TRUE) |>
rdb::plot_topic_segmentation(method = "per_rfrnd")
# count each topic lineage equally
rdb::rfrnds(quiet = TRUE) |>
rdb::plot_topic_segmentation(method = "per_topic_lineage")
# naive count (way faster, but with misleading proportions on tier 2 and 3)
rdb::rfrnds(quiet = TRUE) |>
rdb::plot_topic_segmentation(method = "naive")