Skip to content

Instantly share code, notes, and snippets.

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",
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(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)
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,
#data from http://www.transtats.bts.gov/DL_SelectFields.asp?Table_ID=236&DB_Short_Name=On-Time
#Ask for these fields
#"DAY_OF_WEEK" (IN UI DayOfWeek)
#"FL_DATE" (FlightDate)
#"CARRIER" (Carrier)
#"ORIGIN_CITY_MARKET_ID" (OriginCityMarketID)
#"ORIGIN" (Origin)
#"CRS_DEP_TIME" (CRSDepTime)
#"DEP_DELAY" (DepDelay)
#"ARR_DELAY" (ArrDelay)
library(Lahman)
library(plyr)
library(dplyr)
library(ggplot2)
master = Lahman::Master %>%
select(playerID,birthYear)
bstats <- battingStats() %>%
select(playerID, yearID,BA)
library(ggplot2)
library(dplyr)
AGEMIN=30
AGEMAX=110
NR=AGEMAX-AGEMIN+1
best_ABSDEV=1e6
#If you want the original data, you can get it from
#http://www.ssa.gov/OACT/STATS/table4c6.html
library("dplyr")
library("maps")
library("ggplot2")
library("mapproj")
theme_clean <- function(base_size = 12) {
require(grid)
theme_grey(base_size) %+replace%
theme(
axis.title = element_blank(),
setwd("C:/Dropbox/Projects/20141002_SJDM_Member_Dir/")
library("dplyr")
library("maps")
library("ggplot2")
library("mapproj")
theme_clean <- function(base_size = 12) {
require(grid)
theme_grey(base_size) %+replace%
library(dplyr)
df=read.csv("directory.csv.gz")
df$dept2=tolower(df$dept)
df$dept2[grep("psych",df$dept2)]="Psychology"
df$dept2[grep("marketing",df$dept2)]="Marketing"
df$dept2[grep("economics",df$dept2)]="Economics"
df$dept2[df$dept2=="management"]="Management"
df$dept2[df$dept2=="management department"]="Management"