Skip to content

Instantly share code, notes, and snippets.

library(tidyverse)
library(ggrepel)
library(scales)
setwd("C:/Dropbox/Projects/20170605_Population_Density")
#source https://factfinder.census.gov/bkmk/table/1.0/en/DEC/10_SF1/GCTPH1.US05PR
df <- read_csv("DEC_10_SF1_GCTPH1.US05PR.csv", skip = 1)
#give human readable column headers
library(tidyverse)
library(gganimate)
NUMPLAYERS = 45
ROUNDS = 5000
INITWEALTH = 45
#initialize the bank
#columns wealths of the NUMPLAYERS players
#rows show wealths of each of the ROUNDS ticks of the clocks
library(rvest)
library(tidyr)
library(splines)
library(stringr)
library(ggplot2)
library(dplyr)
setwd("C:/Dropbox/Projects/20160705_Calories_Per_Meal")
men = read_html("http://health.gov/dietaryguidelines/2015/guidelines/appendix-2/") %>%
library(ggplot2)
library(dplyr)
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")
NS = seq(10, 70, by = 5)
ITERS = 1e4
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")
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(dplyr)
library(ggplot2)
library(httr)
setwd("C:/Dropbox/Projects/20160206_Soccer_Scores")
if (!file.exists("20160206_Soccer_Scores.csv.gz")) {
cat("must reread")
}
#population density
#Dan Goldstein 2015
#LIBS
library("rvest")
library("ggplot2")
library("dplyr")
library("animation")
###HARDCODES
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,
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