Skip to content

Instantly share code, notes, and snippets.

@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'}"))
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)
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(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
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()
import csv
import re
import sys
import urllib2
from bs4 import BeautifulSoup
page = urllib2.urlopen("http://fantasyfootballcalculator.com/completed_drafts.php?format=standard").read()
soup = BeautifulSoup(page)
#print soup.prettify()
@tcash21
tcash21 / server.R
Last active December 21, 2015 01:09
DynamicUI example in Shiny
require(shiny)
require(rCharts)
inputChoices <- c("A", "B", "C", "D")
shinyServer(function(input, output, session){
input2Choices <- reactive({
inputChoices[-grep(input$input1, inputChoices)]
})
@tcash21
tcash21 / app.css
Last active December 21, 2015 02:19
Rickshaw chart error in Shiny
.chart_container {
position: relative;
display: inline-block;
font-family: Arial, Helvetica, sans-serif;
}
.rChart {
display: inline-block;
margin-left: 40px;
}
.yAxis {
@tcash21
tcash21 / server.R
Created August 14, 2013 21:58
Understanding Reactivity
require(shiny)
require(rCharts)
inputChoices <- c("A", "B", "C", "D")
adf <- data.frame(val1=sample(inputChoices), val2=sample(inputChoices))
shinyServer(function(input, output, session){
input2Choices <- reactive({
@tcash21
tcash21 / server.R
Last active December 21, 2015 03:28
require(shiny)
require(rCharts)
inputChoices <- c("A", "B", "C", "D")
adf <- data.frame(val1=sample(inputChoices), val2=sample(inputChoices))
shinyServer(function(input, output, session){
input2Choices <- reactive({