How often do governments change in the European Union?

Get the data from ParlGov Website and save the full file path to the variable dbpath.

library(plyr)
library(RSQLite)
library(stringr)
driver = dbDriver("SQLite")

Load the ParlGov Data for EU member states:

gov_db <- dbConnect(driver, dbname = dbpath)
rs <- dbSendQuery(gov_db, "SELECT * FROM view_cabinet WHERE country_name_short IN\n('AUS', 'BEL', 'DNK' ,'FRA', 'FIN', 'DEU', 'GRC', 'IRL', 'ITA',\n'LUX', 'NLD', 'PRT', 'ESP', 'SWE', 'GBR');")
gov <- fetch(rs, n = -1)
dbClearResult(rs)
## [1] TRUE

Reformat data

gov$eyear <- as.numeric(str_extract(gov$election_date, "^[0-9]{1,4}"))
gov$syear <- as.numeric(str_extract(gov$start_date, "^[0-9]{1,4}"))
gov$party_name_short <- as.character(gov$party_name_short)
gov$start_date <- as.Date(gov$start_date)

Delete all cases before 1956 and after 2004

gov <- gov[gov$eyear > 1955 & gov$eyear < 2005, ]
gov <- gov[, c("start_date", "country_name_short", "cabinet_name")]
gov <- gov[duplicated(gov) == FALSE, ]
gov <- gov[order(gov$start_date), ]

How much days are inbetween the different government changes?

n <- nrow(gov)
diff <- gov$start_date[2:n] - gov$start_date[1:(n - 1)]
gov$diff <- c(NA, diff)

Plot the differences in days:

hist(gov$diff, breaks = 120, main = "Frequency of Gov Change in the EU", xlab = "Differences in days")

plot of chunk unnamed-chunk-7

summary(gov$diff)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     0.0    13.0    32.5    54.5    71.2   406.0       1