Last active
February 3, 2020 14:25
-
-
Save cavedave/8bc8c050c8a69f1844dc80ae602ab6fb to your computer and use it in GitHub Desktop.
Dáil Eireann seat map. using r package ggparliament. This code is based on this tutorial https://blog.mypad.in/creating-a-parliament-chart-in-r/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(data.table) | |
require(tidyverse) | |
require(ggparliament) | |
irl<-read.csv("ireland.csv",header=1) | |
#colour column needs to be chr not factor | |
irl<-irl %>% mutate_if(is.factor, as.character) | |
irl_horseshoe <- parliament_data(election_data = irl, | |
party_seats = irl$seats, | |
parl_rows = 5, | |
type = "horseshoe") | |
ir <- ggplot(irl_horseshoe, aes(x, y, colour = party_short)) + | |
geom_parliament_seats() + | |
theme_ggparliament() + | |
labs(colour = NULL, | |
title = "GE2020 Prediction for Irish Parliament", | |
subtitle="who made the prediction and when")+ | |
scale_colour_manual(values = irl$colour, | |
limits = irl$party_short) + | |
theme(legend.position = 'bottom',plot.title = element_text(hjust = 0.5))+ | |
annotate("segment", x = 0, xend = 0, y = 7, yend = 11, | |
colour = "blue")#half way line currently does nto count ceann comhairle | |
ggsave("dail.png") | |
ir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
year | country | house | party_long | party_short | seats | government | colour | |
---|---|---|---|---|---|---|---|---|
2020 | ireland | dail | Fianna Fáil | FF | 50 | 1 | #66BB66 | |
2020 | ireland | dail | Fine Gael | FG | 42 | 1 | #009FF3 | |
2020 | ireland | dail | Sinn Féin | SF | 34 | 1 | #326760 | |
2020 | ireland | dail | Independent | IND/other | 16 | 1 | #DDDDDD | |
2020 | ireland | dail | Green Party | Greens | 9 | 1 | #99CC33 | |
2020 | ireland | dail | Social Democrats | SocDems | 2 | 1 | #752F8B | |
2020 | ireland | dail | People Before Profit Alliance | PBP/Sol | 1 | 1 | #660000 | |
2020 | ireland | dail | Labour Party | LAB | 6 | 1 | #CC0000 |
Author
cavedave
commented
Feb 3, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment