class: center middle <center><img src="https://raw.githubusercontent.com/politanch/swissdd/master/swissdd_noborder.png" height="400px" /></center> ## the swiss direct democracy R-package <a href="https://politanch.github.io/swissdd/index.html" style="text-decoration: none; border-bottom:"><i class="fa fa-github fa-fw"></i>politanch/swissdd</a> <a href="https://twitter.com/thlorusso" style="text-decoration: none; border-bottom:"><i class="fa fa-twitter fa-fw"></i>@thlorusso</a> <a href="https://twitter.com/politanch" style="text-decoration: none; border-bottom:"> / @politanch</a><br> --- name: colors ## About __Swissdd in one sentence:__ > a one stop shop for data on popular votes in Switzerland <br> - Realtime data stream on vote sundays ([cantonal](https://opendata.swiss/de/dataset/echtzeitdaten-am-abstimmungstag-zu-kantonalen-abstimmungsvorlagen) & [national votes](https://opendata.swiss/de/dataset/echtzeitdaten-am-abstimmungstag-zu-eidgenoessischen-abstimmungsvorlagen/)) - Archive of harmonized results of national votes since 1981 - [Geodata](https://opendata.swiss/de/dataset/geodaten-zu-den-eidgenoessischen-abstimmungsvorlagen) of administrative boundaries - The complete [SwissVotes-Database](https://swissvotes.ch/page/dataset) <center><img src="https://blog.digithek.ch/wp-content/uploads/opendata-swiss_logo.png" height="80px" /></center> <br> <center><img src="https://swissvotes.ch/static/images/logo.svg" height="80px" /></center> ??? Swissvotes : Vorabstimmung NR / Kampagnen --- ## About - community driven development (mainly by former [politan.ch](http://politan.ch) Bloggers) - first github version in January 2019 / Available on [CRAN](https://cran.r-project.org/web/packages/swissdd/index.html) since mid 2019 - nine [releases](https://github.com/politanch/swissdd/releases) since then ## Use cases ### [Tamedia-Projections](https://interaktiv.tagesanzeiger.ch/2021/06/abstimmungs-hochrechnungen/) <img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcdn.unitycms.io%2Fimage%2F6EYm_qD545gBJZGFENk-Qy.gif&f=1&nofb=1" height="80px" /> > Merci vielmals für das swissdd #Rstats package - hat das ganze viel einfacher gemacht @politan_ch > @thlorusso @thw_ch und auch danke ans @StatSchweiz für tolle API #opensource https://twitter.com/LucasLeemann/status/1226526006695071745 --- # Realtime data on vote-sundays ### national votes ```r swissdd::get_nationalvotes(geolevel = "district") ``` ``` ## # A tibble: 775 x 15 ## name id canton_id canton_name district_id district_name gebietAusgezaeh… ## <chr> <int> <chr> <chr> <chr> <chr> <lgl> ## 1 Volks… 6410 1 Zürich 101 Bezirk Affol… TRUE ## 2 Volks… 6410 1 Zürich 102 Bezirk Andel… TRUE ## 3 Volks… 6410 1 Zürich 103 Bezirk Bülach TRUE ## 4 Volks… 6410 1 Zürich 104 Bezirk Diels… TRUE ## 5 Volks… 6410 1 Zürich 105 Bezirk Hinwil TRUE ## 6 Volks… 6410 1 Zürich 106 Bezirk Horgen TRUE ## 7 Volks… 6410 1 Zürich 107 Bezirk Meilen TRUE ## 8 Volks… 6410 1 Zürich 108 Bezirk Pfäff… TRUE ## 9 Volks… 6410 1 Zürich 109 Bezirk Uster TRUE ## 10 Volks… 6410 1 Zürich 110 Bezirk Winte… TRUE ## # … with 765 more rows, and 8 more variables: jaStimmenInProzent <dbl>, ## # jaStimmenAbsolut <int>, neinStimmenAbsolut <int>, ## # stimmbeteiligungInProzent <dbl>, eingelegteStimmzettel <int>, ## # anzahlStimmberechtigte <int>, gueltigeStimmen <int>, votedate <date> ``` --- # Realtime data on vote-sundays ### cantonal votes ```r swissdd::get_cantonalvotes(geolevel = "district") ``` ``` ## # A tibble: 155 x 17 ## id canton_name district_id district_name gebietAusgezaehlt ## <int> <chr> <chr> <chr> <lgl> ## 1 211697 ZH 101 Bezirk Affoltern TRUE ## 2 211697 ZH 102 Bezirk Andelfingen TRUE ## 3 211697 ZH 103 Bezirk Bülach TRUE ## 4 211697 ZH 104 Bezirk Dielsdorf TRUE ## 5 211697 ZH 105 Bezirk Hinwil TRUE ## 6 211697 ZH 106 Bezirk Horgen TRUE ## 7 211697 ZH 107 Bezirk Meilen TRUE ## 8 211697 ZH 108 Bezirk Pfäffikon TRUE ## 9 211697 ZH 109 Bezirk Uster TRUE ## 10 211697 ZH 110 Bezirk Winterthur TRUE ## # … with 145 more rows, and 12 more variables: jaStimmenInProzent <dbl>, ## # jaStimmenAbsolut <int>, neinStimmenAbsolut <int>, ## # stimmbeteiligungInProzent <dbl>, eingelegteStimmzettel <int>, ## # anzahlStimmberechtigte <int>, gueltigeStimmen <int>, de <chr>, fr <chr>, ## # it <chr>, rm <chr>, votedate <date> ``` --- # Archive ```r swiss_data <-swissdd::get_nationalvotes(from_date="1990-06-01", geolevel="national") library(ggplot2) ggplot(swiss_data, aes(votedate, stimmbeteiligungInProzent))+ geom_point()+ geom_smooth()+ theme_minimal()+ labs(y="Stimmbeteiligung (%)", x="") ``` <img src="index_files/figure-html/unnamed-chunk-4-1.png" width="60%" /> --- # Maps ```r swissdd::plot_nationalvotes(votedate = "2014-02-09",vote_id = 5800, geolevel = "canton") ``` <img src="index_files/figure-html/unnamed-chunk-5-1.png" width="100%" /> --- # Outlook - Ongoing maintenance to keep a stable version on github / CRAN -- - Integration of further data sources (municipal votes / contextual data) -- __**Contributions & ideas for further improvement are welcome!**__ --- class: center, middle, inverse <a href="https://politanch.github.io/swissdd/index.html" style="color: #095484;text-decoration: none; border-bottom:"><i class="fa fa-github fa-fw"></i>politanch/swissdd</a> <br> # Thanks for your attention! Slides created via the R packages: <a href="https://github.com/yihui/xaringan" style="color: #095484;text-decoration: none; border-bottom:"><i class="fa fa-github fa-fw"></i>yihui/xaringan</a> <br> <a href="https://github.com/gadenbuie/xaringanthemer" style="color: #095484;text-decoration: none; border-bottom:"><i class="fa fa-github fa-fw"></i>gadenbuie/xaringanthemer</a>