Skip to content

Instantly share code, notes, and snippets.

View briatte's full-sized avatar

François Briatte briatte

View GitHub Profile
End of fieldwork/ election date CON LAB LIB DEM OTHER CON LEAD OVER LABOUR Sample Fieldwork dates
15-06-1984 37% 38% 23% 2% -1% n/a June, 1984
15-07-1984 34% 39% 26% 1% -5% n/a July, 1984
15-08-1984 36% 39% 24% 1% -3% n/a Aug, 1984
15-09-1984 39% 38% 21% 2% 1% n/a Sep 1984
15-10-1984 38% 36% 24% 2% 2% n/a Oct, 1984
15-11-1984 42% 33% 24% 1% 9% n/a Nov, 1984
15-12-1984 41% 32% 26% 1% 9% n/a Dec, 1984
15-01-1985 41% 33% 25% 1% 8% n/a Jan, 1985
15-02-1985 38% 36% 25% 1% 2% n/a Feb, 1985
@briatte
briatte / seance1.r
Last active August 29, 2015 14:07
A demo of R + ggplot2, using Guardian/ICM polling data.
# A demo of R + ggplot2, using Guardian/ICM polling data.
# 2014-10-02
# Load packages.
pkgs = c("httr", "ggplot2", "lubridate", "RColorBrewer", "reshape2")
pkgs = lapply(pkgs, FUN = function(x) {
if(!require(x, character.only = TRUE)) {
install.packages(x, quiet = TRUE)
Country Year growth ratio
147 Australia 1946 -3.55795148247978 190.419080068143
148 Australia 1947 2.45947456679709 177.321371355335
149 Australia 1948 6.43753409710857 148.929810515079
150 Australia 1949 6.61199384930806 125.828698553949
151 Australia 1950 6.92020124184758 109.809397999623
152 Australia 1951 4.27261154812808 87.0944792259533
153 Australia 1952 0.904651599574291 86.0664381755866
154 Australia 1953 3.11928028540407 79.8650221084478
155 Australia 1954 6.21681382650683 76.8467028869713
@briatte
briatte / seance2.r
Last active August 29, 2015 14:07
An overview of the Reinhart & Rogoff data, from an exercise by Cosma Shalizi.
# An overview of the Reinhart & Rogoff data, from an exercise by Cosma Shalizi.
# 2014-10-09
#
# package
#
library(ggplot2)
#
@briatte
briatte / incomes.r
Created October 16, 2014 05:22
Piketty and Saez 2003, enhanced fig. 1
## Top incomes data by Piketty and Saez, Sep 2013 update.
## 2014-10-16
## source
# T. Piketty and E. Saez, "Income Inequality in the United States, 1913-1998"
# Quarterly Journal of Economics, 118(1), 2003, 1-39 [ fig. 1, enhanced ]
## packages
@briatte
briatte / incomes.csv
Created October 16, 2014 06:55
Piketty and Saez data
NA. P90.100 P95.100 P99.100 P99.5.100 P99.9.100 P99.99.100
1913 NA NA 17.9600418618677 14.7264569314871 8.61660817145581 2.75501620545077
1914 NA NA 18.1579410592163 15.0802622430197 8.60334089140613 2.72920847365446
1915 NA NA 17.577725 14.57755 9.21885 4.36035
1916 NA NA 18.5730667754062 15.6036449461324 9.86653043001581 4.40493410443468
1917 40.2870418752226 30.3345483573205 17.5994874581952 14.2341917768497 8.35788084805983 3.33076913805183
1918 39.9037275120226 29.2979482993876 15.8832204355484 12.3854950735275 6.74116426024008 2.44816293043196
1919 39.4813240153393 29.307649555521 15.8674148545227 12.2339651877482 6.45397884830736 2.22020659211262
1920 38.1003874377692 27.4694503319667 14.4590420554394 10.9532629518181 5.37143303444607 1.67163862642264
1921 42.8597266399737 30.457060858318 15.4729299864716 11.5988330223682 5.60216500839064 1.68921038823408
@briatte
briatte / an-votes.r
Created November 4, 2014 18:20
exemple de scraper pour les scrutins publics de l'Assemblée nationale (attention, bug sur certaines listes avec un seul votant, car pas de tag <li> dans le code HTML)
library(XML)
library(stringr)
# demo page
h = htmlParse("http://www2.assemblee-nationale.fr/scrutins/detail/(legislature)/14/(num)/947")
g = c("SRC", "UMP", "UDI", "ECOLO", "RAD", "GDR")
k = c("socialiste", "mouvement populaire", "démocrates", "écologiste", "radical", "gauche")
for(i in k) {
@briatte
briatte / example.md
Last active August 29, 2015 14:11
Example cosponsorship network (Iceland 2003–2007)

Iceland 2003-2007

## IDA Exercise 5
## --------------
# This exercise replicates PCA plots using World Values Survey data on
# aggregate confidence in public institutions.
# The data is taken from the Quality of Government dataset. The functions
# contain a mix of base functions and custom packages.
@briatte
briatte / bills1998-2002.html
Last active August 29, 2015 14:12
indexes of Hungarian bills
<!DOCTYPE html>