This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# removes characters from multiple data frame columns | |
# example removes * , % characters | |
dw <- data.frame(gsub("\\*|,|%", "", as.matrix(dw)), stringsAsFactors = FALSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Linkurious 2012, all rights reserved. | |
* Sébastien Heymann <[email protected]>, | |
* Romain Yon <[email protected]> | |
* | |
* Please use http://jsbeautifier.org/ and indent with 2 spaces. | |
* | |
* Lib docs: | |
* http://twitter.github.com/bootstrap/ | |
* http://docs.jquery.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Parse a codebook file with variable and level information. | |
#' | |
#' Parses a codebook file where lines starting at column zero (far left) represet | |
#' variable information (e.g. name, description, type) and indented lines | |
#' (i.e. lines beginning with white space, either tabs or spaces, etc.) represent factor | |
#' levels and labels. | |
#' | |
#' Note that white space at the beginning and end of each line is stripped before | |
#' processing that line. | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doInstall <- TRUE | |
toInstall <- c("ggplot2", "poLCA", "reshape2") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
ANES <- read.csv("http://www.oberlin.edu/faculty/cdesante/assets/downloads/ANES.csv") | |
ANES <- ANES[ANES$year == 2008, -c(1, 11, 17)] # Limit to just 2008 respondents, | |
head(ANES) # remove some non-helpful variables | |
# Adjust so that 1 is the minimum value for each variable: | |
ANES <- data.frame(apply(ANES, 2, function(cc){ cc - min(cc, na.rm = T) + 1 })) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("sna", "ggplot2", "Hmisc", "reshape2") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Empty ggplot2 theme | |
new_theme_empty <- theme_bw() | |
new_theme_empty$line <- element_blank() | |
new_theme_empty$rect <- element_blank() | |
new_theme_empty$strip.text <- element_blank() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plyr) | |
library(zoo) | |
startyr <- 1992 | |
endyr <- 2012 | |
pg <- read.csv("http://www.parlgov.org/stable/static/data/stable-utf-8/view_cabinet.csv",as.is=T) | |
## Exclude GDR | |
pg <- pg[which(pg$country_name_short!="GDR"),] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 | |
height: 600 | |
border: no | |
redirect: https://beta.observablehq.com/@mbostock/d3-choropleth |