This file contains 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
## uncomment this and install from github if you don't have it already | |
# library(devtools) | |
# devtools::install_github("dvanclev/GTrendsR") | |
## load library | |
library(GTrendsR) | |
## create a connection with your gooooogle account details. | |
ch <- gconnect('your google email', 'your google pw') |
This file contains 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
#HWplot.R | |
library(ggplot2) | |
library(reshape) | |
HWplot<-function(ts_object, n.ahead=4, CI=.95, error.ribbon='green', line.size=1){ | |
hw_object<-HoltWinters(ts_object) | |
This file contains 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
## assuming you have a folder full of .csv's to merge | |
## csv's must all have identical column names. | |
folder <- "./path/to/csv/files" | |
filenames <- list.files(folder) | |
all_files <- Reduce(rbind, lapply(filenames, read.csv)) |
This file contains 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
<html> | |
<head> | |
<script src="https://apis.google.com/js/api.js"></script> | |
<script> | |
function start() { | |
gapi.client.init({ | |
'apiKey': 'XXXX', | |
'discoveryDocs': ['https://language.googleapis.com/$discovery/rest?version=v1beta1'] | |
}).then(function() { | |
return gapi.client.language.documents.analyzeSentiment({ |
This file contains 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
## GUIDE TO AUTH2 Authentication in R Shiny (or other online apps) | |
## | |
## Mark Edmondson 2015-02-16 - @HoloMarkeD | http://markedmondson.me | |
## | |
## v 0.1 | |
## | |
## | |
## Go to the Google API console and activate the APIs you need. https://code.google.com/apis/console/?pli=1 | |
## Get your client ID, and client secret for use below, and put in the URL of your app in the redirect URIs | |
## e.g. I put in https://mark.shinyapps.io/ga-effect/ for the GA Effect app, |
This file contains 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
# This example demonstrates running furrr code distributed on 2 AWS instances ("nodes"). | |
# The instances have already been created. | |
library(future) | |
library(furrr) | |
# Two t2.micro AWS instances | |
# Created from http://www.louisaslett.com/RStudio_AMI/ | |
public_ip <- c("34.205.155.182", "34.201.26.217") |
This file contains 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
## see also http://blog.revolutionanalytics.com/2017/06/doazureparallel-updated.html on how to run on Azure | |
## and cloudyr project for AWS https://github.com/cloudyr/aws.ec2 | |
# now also in docs: https://cloudyr.github.io/googleComputeEngineR/articles/massive-parallel.html | |
library(googleComputeEngineR) | |
library(future) | |
## auto auth to GCE via environment file arguments |
This file contains 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
add_months <- function(date, n){ | |
seq(date, by = paste (n, "months"), length = 2)[2] | |
} | |
make_date_ranges <- function(start, end){ | |
starts <- seq(from = start, | |
to = Sys.Date()-1 , | |
by = "1 month") | |
This file contains 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
library("RSiteCatalyst") | |
library("dplyr") | |
SCAuth("peter.meyer@xxx.com:xxx", "xxx") | |
reportSuites <- GetReportSuites() | |
evar <- GetEvars(reportSuites$rsid) #%>% | |
# reportSuite <- reportSuites$rsid | |
This file contains 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
# devtools::install_github("hrbrmstr/vegalite") | |
library(vegalite) | |
library(htmltools) | |
dat <- jsonlite::fromJSON('[ | |
{"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43}, | |
{"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53}, | |
{"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52} | |
]') |