Skip to content

Instantly share code, notes, and snippets.

View briatte's full-sized avatar

François Briatte briatte

View GitHub Profile
@chrishanretty
chrishanretty / pooling_spe.R
Created February 10, 2013 18:21
Pooling the polls for Italy, final version
### Takes as input a Google Docs spreadsheet
### Outputs national and regional level estimates of support
### over time
### Load libraries
library(R2WinBUGS)
library(rjags)
library(RCurl)
library(reshape)
library(foreach)
@xmarquez
xmarquez / List-of-variables-ccp.csv
Last active December 12, 2015 09:39
Code for post on the Normativeness of Democracy
variable Question
cowcode Correlates of War country code (www.correlatesofwar.org).
country Country name.
systyear Year in which the constitutional system was promulgated.
systid Unique identification number for the constitutional system.
evntyear Year of promulgation of the most recent constitutional event.
endyear Year through which the data for the event is guaranteed valid.
evntid Unique identification number for the constitutional event.
evnttype Event type (e.g. amendment, new, etc.).
source What is the source for the text of the Constitution?
@briatte
briatte / crayola.R
Last active December 18, 2015 16:49
Crayola color vector for R
crayola <- structure(c("#EFDECD", "#CD9575", "#FDD9B5", "#78DBE2", "#87A96B",
"#FFA474", "#FAE7B5", "#9F8170", "#FD7C6E", "#000000", "#ACE5EE",
"#1F75FE", "#A2A2D0", "#6699CC", "#0D98BA", "#7366BD", "#DE5D83",
"#CB4154", "#B4674D", "#FF7F49", "#EA7E5D", "#B0B7C6", "#FFFF99",
"#1CD3A2", "#FFAACC", "#DD4492", "#1DACD6", "#BC5D58", "#DD9475",
"#9ACEEB", "#FFBCD9", "#FDDB6D", "#2B6CC4", "#EFCDB8", "#6E5160",
"#CEFF1D", "#71BC78", "#6DAE81", "#C364C5", "#CC6666", "#E7C697",
"#FCD975", "#A8E4A0", "#95918C", "#1CAC78", "#1164B4", "#F0E891",
"#FF1DCE", "#B2EC5D", "#5D76CB", "#CA3767", "#3BB08F", "#FEFE22",
"#FCB4D5", "#FFF44F", "#FFBD88", "#F664AF", "#AAF0D1", "#CD4A4C",
myboot<-function(data, stat, nreps, hist = TRUE) {
estimates<-get(stat)(data)
len<-length(estimates)
container<-matrix(NA, ncol = len , nrow = nreps)
nobs<-nrow(data)
for(i in 1:nreps) {
posdraws<-ceiling(runif(nobs)*nobs)
resample<-data[posdraws,]
container[i,]<-get(stat)(resample)
}
@michalskop
michalskop / index.html
Last active January 3, 2016 20:29
Weighted PCA Model in R
We couldn’t find that file to show.
@yihui
yihui / README.md
Last active March 15, 2017 18:35
A Shiny app based on annyang that responds to voice input
@chrishanretty
chrishanretty / conswing.R
Last active April 24, 2017 20:45
Analysis of swings in Conservative and Labour-held seats, BES data
library(foreign) ## for data import
library(dplyr) ## for chaining ops together
library(ggplot2) ## for plotting
library(reshape2) ## for reshaping
library(hrbrthemes) ## for pretty pictures
library(survey) ## for... uh, survey data
party.colours <- c("#0087DC","#D50000","#FDBB30","#FFFF00","#008142","#99CC33","#70147A","#DDDDDD")
bes <- read.spss("~/Dropbox/2017-forecasting/data/individual/BES2015_W10_Panel_v0.3.sav")

Keybase proof

I hereby claim:

  • I am briatte on github.
  • I am briatte (https://keybase.io/briatte) on keybase.
  • I have a public key whose fingerprint is CF1D 937F 13FD 11F4 9060 57C7 EC0B 0E46 6A4C 4EDE

To claim this, I am signing this object:

@VikParuchuri
VikParuchuri / sentiment_plot.R
Created June 18, 2012 16:12
Generate Sentiment Plot
term<-c("egypt","jordan","israel","saudi")
term_vec<-foreach(i=1:length(all_score_frames),.combine=rbind) %do%
{
score_row<-rep(0,length(term))
for(z in 1:length(score_row))
{
sel_score<-all_score_frames[[i]][all_score_frames[[i]]$term==term[z],"score"]
sel_score[is.na(sel_score)]<-0
if(length(sel_score)==0)
sel_score<-0
@chrishanretty
chrishanretty / threepeat.R
Created December 5, 2017 17:04
Three elections in three years
require(tidyverse)
require(lubridate)
#Data from www.parlgov.org
dat <- read.csv("view_election.csv")
dat <- dat %>%
filter(election_type != "ep") %>%
mutate(election_date = as.Date(election_date)) %>%
filter(election_date > as.Date("1945-01-01")) %>%
distinct(country_name, election_date) %>%
group_by(country_name) %>%