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
install.packages("googleAuthR") |
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
## in global.R | |
library(googleAuthR) | |
options("googleAuthR.scopes.selected" = c("https://www.googleapis.com/auth/urlshortener")) | |
shorten_url <- function(url){ | |
body = list( | |
longUrl = url | |
) |
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(googleAuthR) | |
## change the native googleAuthR scopes to the one needed. | |
options("googleAuthR.scopes.selected" = | |
c("https://www.googleapis.com/auth/urlshortener")) | |
#' Shortens a url using goo.gl | |
#' | |
#' @param url URl to shorten with goo.gl | |
#' |
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
## A script to download and archive Google search analytics | |
## | |
## Demo of searchConsoleR R package. | |
## | |
## Version 1 - 10th August 2015 | |
## | |
## Mark Edmondson (http://markedmondson.me) | |
## load the required libraries | |
## (Download them with install.packages("googleAuthR") and install.packages("searchConsoleR" if necessary |
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
## functions.R | |
library(rga) | |
library(dygraphs) | |
library(zoo) | |
library(tidyr) | |
library(lubridate) | |
library(d3heatmap) | |
library(dplyr) | |
library(stringr) | |
library(DT) |
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
# secrets.R | |
options( | |
mysql = list( | |
"host" = "YOUR SQL IP", | |
"port" = 3306, | |
"user" = "YOUR SQL USER", | |
"password" = "YOUR USER PW", | |
"databaseName" = "onlinegashiny"), | |
rga = list( | |
"profile_id" = "The GA View ID", |
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
## in server.r of a shiny app | |
casualImpactData <- reactive({ | |
## only if we have the data ready | |
validate( | |
need(chartData(), "Need data") | |
) | |
data <- chartData() |
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
## in server.r | |
output$null_plot <- renderDygraph({ | |
## don't output anything unless you have the data ready | |
validate( | |
need(casualImpactData(), "Model Working") | |
) | |
## the data for the plot is in here | |
ci <- casualImpactData()$series | |