This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Multi-page pathing | |
library("d3Network") | |
library("RSiteCatalyst") | |
#### Authentication | |
SCAuth("name", "secret") | |
#### Get All Possible Paths with ("::anything::", "::anything::") | |
pathpattern <- c("::anything::", "::anything::") | |
next_page <- QueuePathing("zwitchdev", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Example | |
{ | |
"timestamp": 1324830675.076, | |
"status": "404", | |
"short_message": "File does not exist: /var/www/no-such-file", | |
"host": "ord1.product.api0", | |
"facility": "httpd", | |
"errno": "ENOENT", | |
"remote_host": "50.57.61.4", | |
"remote_port": "40100", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Installing BreakoutDetection package | |
install.packages("devtools") | |
devtools::install_github("twitter/BreakoutDetection") | |
library(BreakoutDetection) | |
library("RSiteCatalyst") | |
SCAuth("company", "secret") | |
#Get pageviews for each day in 2014 | |
pageviews_2014 <- QueueOvertime('report-suite', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res <- breakout(formatted_df, min.size=24, method='multi', beta=.001, degree=1, plot=TRUE) | |
res$plot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res <- breakout(formatted_df, min.size=5, method='multi', beta=.001, degree=1, plot=TRUE) | |
res$plot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Plot data using ggplot2 | |
library(ggplot2) | |
#Calculate points crossing UCL or LCL | |
pageviews_w_forecast$outliers <- | |
ifelse(pageviews_w_forecast$pageviews > pageviews_w_forecast$upperBound.pageviews, pageviews_w_forecast$pageviews, | |
ifelse(pageviews_w_forecast$pageviews < pageviews_w_forecast$lowerBound.pageviews, pageviews_w_forecast$pageviews, NA)) | |
#Add LCL and UCL labels | |
LCL <- vector(mode = "character", nrow(pageviews_w_forecast)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################# | |
# | |
# Help section Functions for Twitter API | |
# | |
############################################################# | |
function get_help_configuration(; options=Dict{String, String}()) | |
r = get_oauth("https://api.twitter.com/1.1/help/configuration.json", options) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
funcname = (:get_help_configuration, :get_help_languages, :get_help_privacy, :get_help_tos, :get_application_rate_limit_status) | |
endpoint = ("help/configuration.json", "help/languages.json", "help/privacy.json", "help/tos.json", "application/rate_limit_status.json") | |
for (func, endp) in zip(funcname, endpoint) | |
@eval function ($func)(; options=Dict{String, String}()) | |
r = get_oauth($"https://api.twitter.com/1.1/$endp", options) | |
return r.status == 200 ? JSON.parse(r.data) : r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro endpoint(name, path) | |
quote | |
function $(esc(name))(; options=Dict{String, String}()) | |
r = get_oauth($"https://api.twitter.com/1.1/$path", options) | |
return r.status == 200 ? JSON.parse(r.data) : r | |
end | |
end | |
end | |
@endpoint get_help_configuration "help/configuration.json" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REQUEST: | |
{ | |
"reportDescription":{ | |
"dateFrom":"2013-01-01", | |
"dateTo":"2013-11-16", | |
"reportSuiteID":"", | |
"segment_id":"53c059aee4b07cd3c4332163", | |
"metrics":[ | |
{ | |
"id":"bouncerate" |