Skip to contents

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 columns topics_tier_1, topics_tier_2 and topics_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.

Value

A plotly object.

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_3s. See the full topic hierarchy for details.

See also

Examples

# count each referendum equally
rdb::rfrnds(quiet = TRUE) |>
  rdb::plot_topic_segmentation(method = "per_rfrnd")
state organisationsocial policypublic financeenvironment and living spacetransport and infrastructureeconomyeducation and researchsecurity policyculture, religion and mediaenergyagricultureforeign policyinstitutionspolitical systemlegal systemcitizens' rightsnational identityfederalismnot definedhealthsocial groupssocial securitynot definedtaxationpublic expenditurebudget cuts and remediation measuresnot definedfinancial systemenvironmenthousingsoilnot definedroad transportnot definedtransport policyrail transportshippingair transporttelecommunicationspostemploymenteconomic policytourism and leisurefinancenot definedschoolseducation policyprofessional and vocational educationuniversitiesresearchnot definedpublic securityarmynot definednational economic supplycultural policyreligion, churchesmedia and communicationsportlanguage policynot definedenergy policynuclear energyalternative energyhydro-electric powernot definedoil and gasagricultural policyfishing, hunting and petsforestrynot definedlivestockcrop productionEuropean policyposition on foreign policybilateral treatiesinternational organisationsnot definedforeign trade policydevelopment cooperationSwiss abroaddiplomacygovernment, administrationparliamentcourtsnot definednational bankconstitutionelectoral systemnot definedprocedure for constitutional reformlegislative procedureprivate lawcriminal lawfundamental rightsnot definedcitizenshipdata protectioninternational lawvoting rightsnot definedcitizens' initiativesreferendumterritorial questionsintergovernmental relationsdivision of tasksnot definedhealth policyaddictive substancesmedicinesnot definedreproductive medicinemedical research and technologychildren and young peoplefamily policyimmigration policysenior citizensstatus of womenpersons with disabilitieshomosexualsrefugeesnot definedhealth and accident insurancepension insurancewelfareunemployment insurancenot defineddisability insuranceoccupational benefits provisionmaternity insurancecompensation for loss of earnings for persons on military service or civil protection dutytax policydirect taxationnot definedindirect taxationtax systemenvironmental policyprotection of nature and cultural heritageanimal protectionnot definedwater pollution controlwastesoil protectionnoise protectionair quality controlbuilding of residential housing, property ownershipnot definedtenancy issuesspatial planningland lawnot definednot definedroad constructionheavy trafficnot definedurban transporttransit trafficnot definedpassenger trafficgoods trafficemployment conditionsworking hoursnot definedemployment policyindustrial relationsstructural policynot definedconsumer protectioncompetition policypricing policyshort-term economic policylottery and gamblinghospitalitytourismnot definedbanks, stock exchange, insurancenot definedmonetary policynot definedgenetic engineeringanimal testingpolicecivil protectionnot definedstate securityarmsmilitary facilitiesarmed forces in generalnot definedconscientious objection, civilian servicemilitary organisationabolition of the armed forcesmilitary traininginternational deploymentradio, television and electronic medianot definedmedia policypressfreedom of the mediaEUnot definedEEAother European organisationsEFTAindependencenot definedneutralityother international organisationsUNnot definednot definedcustoms
# count each topic lineage equally rdb::rfrnds(quiet = TRUE) |> rdb::plot_topic_segmentation(method = "per_topic_lineage")
state organisationsocial policypublic financeeducation and researchenvironment and living spacetransport and infrastructureeconomysecurity policyculture, religion and mediaenergyagricultureforeign policyinstitutionspolitical systemlegal systemcitizens' rightsfederalismnational identitynot definedsocial groupshealthsocial securitynot definedtaxationpublic expenditurebudget cuts and remediation measuresnot definedfinancial systemschoolseducation policyprofessional and vocational educationuniversitiesresearchnot definedenvironmenthousingsoilnot definedroad transportnot definedtransport policyrail transportair transportshippingtelecommunicationspostemploymenteconomic policytourism and leisurefinancenot definedpublic securityarmynot definednational economic supplycultural policyreligion, churchesmedia and communicationsportlanguage policynot definedenergy policynuclear energyalternative energyhydro-electric powernot definedoil and gasfishing, hunting and petsagricultural policyforestrynot definedlivestockcrop productionEuropean policyposition on foreign policybilateral treatiesinternational organisationsnot definedforeign trade policydevelopment cooperationSwiss abroaddiplomacygovernment, administrationparliamentcourtsnot definednational bankconstitutionelectoral systemnot definedprocedure for constitutional reformlegislative procedurecriminal lawprivate lawnot definedfundamental rightscitizenshipdata protectioninternational lawvoting rightsnot definedcitizens' initiativesreferendumintergovernmental relationsterritorial questionsdivision of tasksnot definedchildren and young peoplefamily policyimmigration policysenior citizensstatus of womenpersons with disabilitiesrefugeeshomosexualsnot definedhealth policyaddictive substancesmedicinesnot definedmedical research and technologyreproductive medicinepension insurancehealth and accident insurancewelfaredisability insuranceunemployment insurancenot definedoccupational benefits provisionmaternity insurancecompensation for loss of earnings for persons on military service or civil protection dutytax policydirect taxationnot definedindirect taxationtax systemnot definedgenetic engineeringanimal testingenvironmental policyprotection of nature and cultural heritagenot definedanimal protectionwater pollution controlsoil protectionwastenoise protectionair quality controlnot definedbuilding of residential housing, property ownershiptenancy issuesspatial planningland lawnot definednot definedroad constructionheavy trafficnot definedurban transporttransit trafficnot definedpassenger trafficgoods trafficemployment conditionsworking hoursnot definedemployment policyindustrial relationsnot definedstructural policyconsumer protectioncompetition policypricing policyshort-term economic policylottery and gamblinghospitalitytourismnot definedbanks, stock exchange, insurancenot definedmonetary policypolicecivil protectionnot definedstate securityarmsmilitary facilitiesarmed forces in generalnot definedconscientious objection, civilian servicemilitary organisationmilitary trainingabolition of the armed forcesinternational deploymentradio, television and electronic medianot definedmedia policyfreedom of the mediapressEUnot definedEEAother European organisationsEFTAindependencenot definedneutralityother international organisationsnot definedUNnot definedcustoms
# naive count (way faster, but with misleading proportions on tier 2 and 3) rdb::rfrnds(quiet = TRUE) |> rdb::plot_topic_segmentation(method = "naive")
state organisationsocial policypublic financeenvironment and living spaceeconomyeducation and researchtransport and infrastructuresecurity policyculture, religion and mediaagricultureforeign policyenergyinstitutionspolitical systemlegal systemcitizens' rightsfederalismnational identitysocial groupshealthsocial securitytaxationpublic expenditurebudget cuts and remediation measuresfinancial systemenvironmenthousingsoilemploymenteconomic policytourism and leisurefinanceschoolseducation policyprofessional and vocational educationuniversitiesresearchroad transporttransport policyrail transportair transportshippingtelecommunicationspostpublic securityarmynational economic supplycultural policymedia and communicationreligion, churchessportlanguage policyfishing, hunting and petsagricultural policyforestrylivestockcrop productionEuropean policyposition on foreign policyinternational organisationsbilateral treatiesforeign trade policydevelopment cooperationdiplomacySwiss abroadenergy policynuclear energyalternative energyhydro-electric poweroil and gasgovernment, administrationparliamentcourtsnational bankconstitutionelectoral systemprocedure for constitutional reformlegislative procedurecriminal lawprivate lawfundamental rightscitizenshipdata protectioninternational lawvoting rightscitizens' initiativesreferendumintergovernmental relationsterritorial questionsdivision of taskschildren and young peoplefamily policyimmigration policysenior citizensstatus of womenpersons with disabilitiesrefugeeshomosexualshealth policyaddictive substancesmedicinesmedical research and technologyreproductive medicinepension insurancehealth and accident insurancewelfaredisability insuranceunemployment insuranceoccupational benefits provisionmaternity insurancecompensation for loss of earnings for persons on military service or civil protection dutytax policydirect taxationindirect taxationtax systemenvironmental policyprotection of nature and cultural heritageanimal protectionwater pollution controlsoil protectionwastenoise protectionair quality controlbuilding of residential housing, property ownershiptenancy issuesspatial planningland lawemployment conditionsworking hoursemployment policyindustrial relationsstructural policyconsumer protectioncompetition policypricing policyshort-term economic policylottery and gamblinghospitalitytourismbanks, stock exchange, insurancemonetary policygenetic engineeringanimal testingroad constructionheavy trafficurban transporttransit trafficpassenger trafficgoods trafficpolicecivil protectionstate securityarmsmilitary facilitiesarmed forces in generalconscientious objection, civilian servicemilitary organisationmilitary trainingabolition of the armed forcesinternational deploymentradio, television and electronic mediamedia policyfreedom of the mediapressEUEEAother European organisationsEFTAindependenceneutralityother international organisationsUNcustoms