Skip to content

Instantly share code, notes, and snippets.

import csv
import re
import urllib2
from bs4 import BeautifulSoup
page = urllib2.urlopen("http://fantasyfootballcalculator.com/completed_drafts.php?format=standard").read()
soup = BeautifulSoup(page)
#print soup.prettify()
library(pitchRx)
## scrape all pitchFX data from May 4th, 2012
dat <- scrapeFX(start = "2012-05-04", end = "2012-05-04")
## Join tables for data analysis
pitchFX <- join(dat$pitch, dat$atbat, by = c("num", "url"), type = "inner")
pitches <- subset(bos, pitcher_name = "Jon Lester")
facets <- facet_grid(. ~ stand)
strikeFX(pitches, geom = "tile") + facets
setwd("R/")
setwd("NFL Play-by-Play Data 2002-2012/")
## read in the sweet, sweet NFL data
seasons <- c(2002:2011)
n <- read.csv("2012_nfl_pbp_data_reg_season.csv", header=TRUE, stringsAsFactors=FALSE)
n1 <- read.csv("2002_nfl_pbp_data.csv", header=TRUE, stringsAsFactors=FALSE)
n <- n[,-which(is.na(match(colnames(n), colnames(n1))))]
for(i in seasons){
n1 <- read.csv(paste(i, "_nfl_pbp_data.csv", sep=""), header=TRUE, stringsAsFactors=FALSE)
library(XML)
library(RCurl)
library(ggplot2)
results <- c()
## Loop through the 30 pages of player data
for(i in 1:30){
theURL <- paste("http://www.nhl.com/ice/playerstats.htm?fetchKey=20122ALLSASAll&viewName=summary&sort=points&pg=", i, sep="")
webpage <- getURL(theURL)
@tcash21
tcash21 / gvisBubbleChart
Created March 14, 2012 19:41
gvisBubbleChart
g<-gvisBubbleChart(Fruits, idvar="Fruit", xvar="Date", yvar="Sales", colorvar="Fruit", sizevar="Profit", options=list(hAxis.format="{format:'Y-MMM-d'}"))