Get the function out of the RMD
file and start to put some structure to it.
Tear it apart.
u = "https://gist.githubusercontent.com/Btibert3/c20c59a2b925562aa050/raw/f5a395239b78fc649432cfb6fcb7c22d8877225c/queryAPI.r"
library(twitteR) | |
library(RMySQL) | |
mydb = dbConnect(MySQL(), user='username', password='password', dbname='tweets', host='hostname', port=3306) | |
load("OAuth.dat") | |
registerTwitterOAuth(my_oauth) | |
## Capture tweets within 150 mile radius of Boston that mention 'Patriots' | |
p<-tryCatch(searchTwitter("Patriots", geocode=c("42.368750,-71.055279,150mi"), n=750), error=function(e) print(e$message)) |
g<-gvisBubbleChart(Fruits, idvar="Fruit", xvar="Date", yvar="Sales", colorvar="Fruit", sizevar="Profit", options=list(hAxis.format="{format:'Y-MMM-d'}")) |
Updated the queryAPI
and created a new function, stattle
that wraps it and makes walking easier. jsonlite
is great, but I started to bump
into some issues with dplyr::bind_rows
. Right now these two functions play nice together, but needs to be further tested.
## source the functions
devtools::source_url('https://gist.githubusercontent.com/tcash21/44667f7b8578cc8e061e/raw/fdac84a0a445e448427cc3557e8c9393ce1fa470/queryAPI.r')
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() |
require(shiny) | |
require(rCharts) | |
inputChoices <- c("A", "B", "C", "D") | |
shinyServer(function(input, output, session){ | |
input2Choices <- reactive({ | |
inputChoices[-grep(input$input1, inputChoices)] | |
}) |
.chart_container { | |
position: relative; | |
display: inline-block; | |
font-family: Arial, Helvetica, sans-serif; | |
} | |
.rChart { | |
display: inline-block; | |
margin-left: 40px; | |
} | |
.yAxis { |