Skip to content

Instantly share code, notes, and snippets.

View briatte's full-sized avatar

François Briatte briatte

View GitHub Profile
@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 / example.r
Created February 11, 2015 15:10
testing https://github.com/kalimu/genderizeR with Finnish MP names
x = c("Aaltonen, Markus Sakari", "Stubb, Cai-Göran Alexander", "Ahde, Matti Allan",
"Saarakkala, Vesa-Matti", "Aho, Esko Tapani", "Piirainen, Raimo Olavi",
"Jääskeläinen, Pietari Osmo", "Juurikkala, Timo Johannes",
"Jokinen, Kalle Johannes", "Aho, Raila Orvokki", "Ahonen, Risto Sakari",
"Aittoniemi, Sulo Eerikki", "Ahvenjärvi, Sauli Sakari", "Mäkisalo-Ropponen, Merja Elina",
"Mäntylä, Hanna Katariina", "Autto, Heikki Samuli", "Ajo, Aimo Olavi",
"Mäntymaa, Markku Antero", "Mölsä, Martti Kullervo", "Niikko, Mika Ilari",
"Eerola, Juho Seppo Antero", "Eestilä, Markku Yrjö", "Packalén, Tom Erik",
"Elomaa, Ritva Tuulikki", "Pekonen, Aino-Kaisa Ilona", "Pelkonen, Jaana Maarit",
"Eloranta, Eeva-Johanna", "Donner, Jörn Johan", "Grahn-Laasonen, Sanni Kaisa",
@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"),

Using open legislative data to map bill co-sponsorship networks in 15 countries

[Published at Opening Parliament.org](published at http://blog.openingparliament.org/post/113803051548/using-open-legislative-data-to-map-bill).

A few years back, Kamil Gregor published a post on the OpeningParliament.org blog under the title “Visualizing politics: Network analysis of bill sponsors”.

His post, which focused on the lower chamber of the Czech Parliament, showed how basic social network analysis can support the exploration of parliamentary work, by revealing the ties that Members of Parliament create between each other through the cosponsorship of private bills.

As Kamil observed, this kind of research is heavily dependent on open legislative data, which do not exist for many parliaments. There has been, however, some amount of progress in that area -- and even when parliaments do not develop open data _portals

@briatte
briatte / fn-data.r
Last active December 18, 2015 14:32
scrape the Front national's online news items
library(dplyr)
library(ggplot2)
library(httr)
library(lubridate)
library(rvest)
library(stringr)
dir.create("pages", showWarnings = FALSE)
b = data.frame()
library(ROAuth)
requestURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "https://api.twitter.com/oauth/authorize"
# replace XYZ with your Twitter API consumer key
consumerKey <- "XYZ"
# replace ... with your Twitter API consumer secret
# introduction vite fait au t-test (comparaison de moyennes)
# le jeu de données fictif ci-dessous est à remplacer par
# data = read.csv("/chemin/vers/votre/fichier.csv", stringsAsFactors = FALSE)
data = data.frame(site = letters[ 1:15 ],
categorie = sample(LETTERS[ 1:2 ], 15, replace = TRUE),
mesure = runif(15))
# voilà à quoi doivent ressembler les données
@briatte
briatte / ess.r
Last active August 29, 2015 14:21
library(dplyr)
library(ggplot2)
library(readr)
library(survey)
ess5 = read_csv("ESS5_FR_SDDF.csv") %>%
left_join(read_csv("ESS5FR.csv"), by = c("cntry", "idno")) %>%
ess_prepare
ess5 = svydesign(