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"| .chart_container { | |
| position: relative; | |
| display: inline-block; | |
| font-family: Arial, Helvetica, sans-serif; | |
| } | |
| .rChart { | |
| display: inline-block; | |
| margin-left: 40px; | |
| } | |
| .yAxis { |
| .chart_container { | |
| position: relative; | |
| display: inline-block; | |
| font-family: Arial, Helvetica, sans-serif; | |
| } | |
| .rChart { | |
| display: inline-block; | |
| margin-left: 40px; | |
| } | |
| .yAxis { |
| .chart_container { | |
| position: relative; | |
| display: inline-block; | |
| font-family: Arial, Helvetica, sans-serif; | |
| } | |
| .rChart { | |
| display: inline-block; | |
| margin-left: 40px; | |
| } | |
| .yAxis { |
| .chart_container { | |
| position: relative; | |
| display: inline-block; | |
| font-family: Arial, Helvetica, sans-serif; | |
| } | |
| .rChart { | |
| display: inline-block; | |
| margin-left: 40px; | |
| } | |
| .yAxis { |
| library(shiny) | |
| library(ggplot2) | |
| library(shinyIncubator) | |
| # Define server logic required to summarize and view the selected dataset | |
| shinyServer(function(input, output, session) { | |
| getData <- function(){ | |
| x <- seq(Sys.Date() - (input$nobs - 1), Sys.Date(), by="days") | |
| y <- rnorm(input$nobs, 5, 100) |
| .well { | |
| width: 250px; | |
| } | |
| 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)) |
| library(ROAuth) | |
| requestURL <- "https://api.twitter.com/oauth/request_token" | |
| accessURL <- "https://api.twitter.com/oauth/access_token" | |
| authURL <- "https://api.twitter.com/oauth/authorize" | |
| consumerKey <- 'XXXXX' | |
| consumerSecret <- 'XXXXXX' | |
| my_oauth <- OAuthFactory$new(consumerKey = consumerKey, | |
| consumerSecret = consumerSecret, | |
| requestURL = requestURL, |
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')