Skip to content

Instantly share code, notes, and snippets.

Avatar
🦑
Tappity tap tap

Mark MarkEdmondson1234

🦑
Tappity tap tap
View GitHub Profile
@MarkEdmondson1234
MarkEdmondson1234 / server.r
Created Feb 16, 2014
Cascading Menu System for Shiny
View server.r
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) {
@MarkEdmondson1234
MarkEdmondson1234 / HWplot.R
Created Jun 18, 2014
A function to plot a holtWinters timeseries in ggplot2
View HWplot.R
#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)
@MarkEdmondson1234
MarkEdmondson1234 / auth.r
Last active Feb 24, 2020
Authenticate a Twitter app in R
View auth.r
# Refer to https://rtweet.info/
@MarkEdmondson1234
MarkEdmondson1234 / processTweets.r
Last active Aug 29, 2015
A couple of functions used to process Tweets after fetching
View processTweets.r
### 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,
View plotTweets.R
### 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)
######################################################################
@MarkEdmondson1234
MarkEdmondson1234 / r-installation-debain-wheezy
Last active Feb 10, 2016
Installation of R, Rstudio, OpenCPU on GCE Debain Wheezy image, details on how to in the blogpost http://markedmondson.me/run-r-rstudio-and-opencpu-on-google-compute-engine-free-vm-image
View r-installation-debain-wheezy
### 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
@MarkEdmondson1234
MarkEdmondson1234 / grabCSVColumn.sh
Created Oct 15, 2014
Input in a csv and a column, get out another file with just that column
View grabCSVColumn.sh
#!/bin/bash
INPUT=
OUTPUT="output.txt"
COL=1
while [ $# -gt 0 ]
do
case "$1" in
-f) INPUT="$2"; shift;;
@MarkEdmondson1234
MarkEdmondson1234 / setup.R
Created Nov 2, 2014
Setup rga() and CausalImpact() packages
View setup.R
## 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)
@MarkEdmondson1234
MarkEdmondson1234 / getGAdata.R
Last active Aug 29, 2015
Get the GA data for a profile
View getGAdata.R
## 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"
@MarkEdmondson1234
MarkEdmondson1234 / causalImpactOnGA.R
Last active Aug 29, 2015
Apply CausalImpact package to the GA output.
View causalImpactOnGA.R
## 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)