Skip to content

Instantly share code, notes, and snippets.

library(ggplot2)
library(tidyr)
library(dplyr)
dfs=structure(list(Sex = structure(c(1L, 2L, 1L, 1L, 1L, 2L, 1L,
1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L,
1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L,
library(dplyr)
library(xtable)
setwd("C:/Dropbox/Projects/20141211_Which_Airline_Loyalty")
load(file="2013flights.Rdata")
ldf = df %>%
group_by(origin_market_id,carrier) %>%
summarize(Departures = length(delay))
library(ggplot2)
df=structure(list(streaksPerCentury = c(8095.68, 4022.65, 1997.74,
989.41, 489.31, 243.43, 120.66, 60.09, 29.94, 14.86, 7.57, 3.88,
2.06, 1.19, 0.65, 0.3, 0.15, 0.07, 0.03, 0.01, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
library(ggplot2)
library(dplyr)
#Effective date for same-sex marraige from
#https://en.wikipedia.org/wiki/Same-sex_marriage_in_the_United_States
#with June 2015 for states that had not approved by that date
#Republican two-party vote share in the 2012 election from
#usaelectionatlas.org h/t David Rothschild
df=structure(list(state = structure(1:50, .Label = c("Alabama",
state state_abbrev republican_vote effective_date
1 Alabama AL 61.2 2015.46
2 Alaska AK 57.3 2014.79
3 Arizona AZ 54.6 2014.79
4 Arkansas AR 62.2 2015.46
5 California CA 38.1 2008.46
6 Colorado CO 47.3 2014.79
7 Connecticut CT 41.2 2008.88
8 Delaware DE 40.6 2013.54
9 Florida FL 49.6 2015.04
library(ggplot2)
library(dplyr)
#data from http://www.doccs.ny.gov/Research/annotate.asp
#escape duration is the max duration for the coding
#e.g. <6 hours is coded as 6 hours, 1-2 days coded as 48h
df=structure(list(year = c(2002L, 2002L, 2002L, 2002L, 2003L, 2003L,
2003L, 2003L, 2003L, 2003L, 2004L, 2004L,
2005L, 2005L, 2006L, 2006L, 2006L, 2006L,
#population density
#Dan Goldstein 2015
#LIBS
library("rvest")
library("ggplot2")
library("dplyr")
library("animation")
###HARDCODES
library(dplyr)
library(ggplot2)
library(httr)
setwd("C:/Dropbox/Projects/20160206_Soccer_Scores")
if (!file.exists("20160206_Soccer_Scores.csv.gz")) {
cat("must reread")
}
library(dplyr)
library(xtable)
#HC01_EST_VC17
#Total; Estimate; Percent bachelor's degree or higher
#HC01_EST_VC14
#Total; Estimate; Population 25 years and over - Graduate or professional degree
#Note: I stripped out a second header line in preproc
library(ggplot2)
library(dplyr)
setwd("C:/Dropbox/Projects/20160610_Range_Heuristic")
v_get_random_betas = Vectorize(rbeta)
ALPHAS = c(1, 2, 5, 1)
BETAS = c(5, 5, 5, 1)
DISTS = c("Floor", "Left of center", "Normalish", "Uniform")