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(shiny) | |
## test dataframe | |
df <- data.frame(option1 = c("A","A","B","B","C","C"), | |
option2 = c("A1","A2","B3","B1","C2","C3"), | |
option3 = c(T,F,T,F,T,F), | |
option4 = c("a","b","c","d","e","f")) | |
shinyServer(function(input, output, session) { | |
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
# Refer to https://rtweet.info/ |
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
### tweetdata.r | |
### Fetch Twitter data and Data Transformations | |
### Requires you have authenticated in auth.R | |
### 15th June 2014 | |
### Mark Edmondson @HoloMarkeD | |
### | |
### For use with Twitter API, processTweets() takes the df$tweetDF data.frame as input | |
### And calculates/transforms data for the plots | |
processTweets <- function(tweetDF, |
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
### plotTweets.r | |
### Plot out tweets | |
### Requires you have authenticated in auth.R and processed in tweetdata.R | |
### 15th June 2014 | |
### Mark Edmondson @HoloMarkeD | |
### | |
library(ggplot2) | |
###################################################################### |
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
### r-installation-debain-wheezy | |
#### setup commands to setup R, RStudio and OpenCPU on a Google Compute Engine Wheezy instance | |
#### Mark Edmondson 29 June 2014 | |
## | |
## No original work, all taken from these sources: | |
## https://github.com/jeroenooms/opencpu-deb/blob/master/build-on-debian.md | |
## https://support.rstudio.com/hc/communities/public/questions/200651456-RStudio-server-not-installable-on-Debian-Wheezy-just-released-this-week- | |
## http://cran.r-project.org/bin/linux/debian/README.html | |
# need to be sudo for all below |
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
#!/bin/bash | |
INPUT= | |
OUTPUT="output.txt" | |
COL=1 | |
while [ $# -gt 0 ] | |
do | |
case "$1" in | |
-f) INPUT="$2"; shift;; |
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
## Setup | |
## below only needed first time if you haven't the packages installed | |
# install.packages("devtools") | |
# library(devtools) | |
# devtools::install_github("google/CausalImpact") | |
## load the libraries | |
library(CausalImpact) | |
library(rga) |
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
## pull in the GA data | |
# get list of profiles | |
profiles <- ga$getProfiles() | |
# View the profiles table, and pick the profile you want and put in the profile ID below | |
UA <- "XXXXXXX" | |
# choose the dates you want to pull in data for | |
date_before = "2014-09-01" |
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
## do the causalImpact | |
# here the effect took place on the 200th day of the data imported, so the pre.period = 200 | |
# Data is examined and compared in the post perid to day 244 | |
impact <- CausalImpact(data = gadata$visits, | |
pre.period = c(1,200), | |
post.period = c(201,244), | |
model.args = NULL, | |
bsts.model = NULL, | |
post.period.response = NULL, | |
alpha = 0.05) |
OlderNewer