[This article was first published on Wiekvoet, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Pretty soon we will be having European Elections. I cannot tell when exactly, that depends on country. Over here the elections get a some attention, which is how I ran into data from votewatch.eu on voting of MEPs. That was just too interesting, so I made some plots.Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Data
Data describe how often MEPs voted what in the European Parliament. For each MEP the number of votes, percentages Yes, No, Abstain, number of elections and number of elections not voted. A description of the data can be found in this pdf.From practical point of view there is a spreadsheet. I did some preprocessing on it. Two MEPs had quotes in their names, which did not play nice with read.xls, these quotes were removed. The column headers were a bit long, these were shortened. Finally, read.xls converts to .csv, then reads the data. In the .csv the data are rounded as you see them in the .xls. All percentages were originally rounded to whole numbers but internally as reals. Decimals were added in the display so they could be used later on. The reading itself is fairly basic.
library(gdata)
r1 <- read.xls(‘votewatch-europe-yes-no-votes-data-11-december-2013.preprocessed.xls’,
stringsAsFactors=TRUE)
tail(r1,n=2)
Last.Name First.Name Country Group National.Party
765 FARAGE Nigel United Kingdom EFD United Kingdom Independence Party
766 BLOOM Godfrey United Kingdom EFD United Kingdom Independence Party
Sdate TotalDone pYES pNO pAbstain TotalPossible pNoVote
765 2009-07-14 323 1.238390 86.37771 12.3839 514 20.83333
766 2009-07-14 216 0.925926 77.77778 21.2963 514 29.18033
r1$Date <- as.Date(r1$Sdate)
European Parliament
As can be seen from the data, each MEP has a number of defining properties. Godfrey Bloom is from the UK, within Europe he is member of the EFD (Europe of Freedom and Democracy) group, within the UK he is member of UKIP. As far as I understand membership of these groups may change after the elections, but in the past years it was EFD. Read wikipedia: EP groups for more details. Not all groups are equal, EPP is clearly the largest. NI is Non-Inscrits (abbreviated NI; English: Non-Attached Members). S&D gets relevelled, because that improves the Mosaic plots later.r1$Group <- relevel(r1$Group,’S&D’)
dotchart(as.numeric(table(r1$Group)),
labels=levels(r1$Group),
xlim=c(0,300))
The number of parties within each group varies too. S&D gets representations from every country, while others much less so. See also wikipedia 2009 elections
parties <- unique(subset(r1,,c(Country,Group,National.Party)))
mosaicplot(~Group + Country,
data=parties[r1$National.Party != ‘Independent’,],
color=rainbow(nlevels(r1$Country)/2),
main=’Number of parties per country’,
las=2,cex=.7)
I case you wonder about the big square for Italy in EPP:
parties[parties$Country==’Italy’ & parties$Group==’EPP’,]
Country Group National.Party
17 Italy EPP Unione dei Democratici cristiani e dei Democratici di Centro
36 Italy EPP Futuro e Libertà per l’Italia
47 Italy EPP Il Popolo della Libertà
50 Italy EPP Unione Democratici per l’Europa
104 Italy EPP Südtiroler Volkspartei (Partito popolare sudtirolese)
115 Italy EPP Fratelli d’Italia – Centrodestra Nazionale
675 Italy EPP Independent
Finally, number of MEPs per country and group. France and Germany have quite a big part in EPP. The UK is the one country not present in EPP, however, they are very big in ECR. I wonder if they would feel better represented if they were closer to the power of EPP?
mosaicplot(~Group+Country,data=r1,
color=rainbow(nlevels(r1$Country)/2),
main=’Number of MEPs’,
las=2,cex=.7)
Voting
Voting for this part of the data is ‘final legislation’. There are many more votes in the second page of the spreadsheet. First we make some variables to ease our plotting.
r1$nYES=round(r1$pYES*r1$TotalDone/100)
r1$nNO=round(r1$pNO*r1$TotalDone/100)
r1$nAbstain=round(r1$pAbstain*r1$TotalDone/100)
r1$nNoVote=round(r1$pNoVote*r1$TotalPossible/100)
r1$nNotIn <- r1$TotalPossible-r1$nNoVote-r1$TotalDone
r1$pnNotYN <- 100*with(r1,
(nNotIn+nNoVote+nAbstain)/TotalPossible)
library(lattice)
The first plot shows the proportion of votes where MEPs voted neither Yes nor No. It would seem EPP, S&D and ALDE/ADLE are disciplined voters. In contrast, the independents and EFD got many MEPs who don’t use their votes.densityplot(~ pnNotYN | Group,
from=0,to=100,
data=r1,
xlab=’MEPs Percentage votes abstained, not voted or not present’,
main=”MEP’s neither Yes nor No”)
Finally, the yes voters. It would seem EPP, S&D and ALDE/ADLE support most final legislation. I imagine that is because they created most of it too. Certainly something opposed by EPP as block, will find it difficult to get a majority.
densityplot( ~I(100*nYES/TotalPossible) | Group,
data=r1,
xlab=’Percentage Yes of MEP’,
from=0,to=100,
main=”MEP’s percentage votes YES”)
To leave a comment for the author, please follow the link and comment on their blog: Wiekvoet.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.