Skip to content

Instantly share code, notes, and snippets.

View briatte's full-sized avatar

François Briatte briatte

View GitHub Profile
@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>
@briatte
briatte / ergm.r
Last active August 29, 2015 14:14
m = sum(n %e% "raw") / network.dyadcount(n)
init.sum = log(m)
npar = length(summary(f, response = "raw"))
M = ergm(f, response = "raw",
reference = ~Poisson,
control = control.ergm(seed = 9042,
parallel = parallel::detectCores(),
#
@briatte
briatte / README.md
Last active August 29, 2015 14:15
Modélisation de la modularité des réseaux de cosignatures législatives de ce dossier : https://github.com/briatte/parlnet

Replication archive for François Briatte, "Les réseaux de cosignatures législatives de quinze parlements européens", 2015.

Get the paper and its appendix at http://f.briatte.org/research/ferney-paper.pdf.

DATA

The data.csv file contains information on the networks produced by the parlnet repository available at https://github.com/briatte/parlnet.

Observations are cosponsorship networks from 19 parliamentary chambers in 15 countries over 96 legislatures. Variables are:

@briatte
briatte / charlie-data.r
Last active August 29, 2015 14:16
scrape front covers from Charlie Hebdo – source: http://stripsjournal.canalblog.com/
#
# download 338 Charlie Hebdo covers with keywords
#
library(dplyr)
library(XML)
library(lubridate)
library(stringr)
library(ggplot2)
@briatte
briatte / revues-data.r
Last active August 29, 2015 14:16
scrape author metadata from 'sociology' journals on cairn.info – start with revues.r
data = "revues-soc.csv"
if(!file.exists(data)) {
dir.create("rev", showWarnings = FALSE)
dir.create("num", showWarnings = FALSE)
r = "http://www.cairn.info/"
download.file(paste0(r, "discipline.php?POS=11&TITRE=ALL"),