Skip to content

Instantly share code, notes, and snippets.

View chipoglesby's full-sized avatar
🏠
Working from home

Chip Oglesby chipoglesby

🏠
Working from home
View GitHub Profile
/*********************************************
* Automated Creative Testing With Statistical Significance
* Version 2.1
* Changelog v2.1
*   - Fixed INVALID_PREDICATE_ENUM_VALUE
* Changelog v2.0
*   - Fixed bug in setting the correct date
*   - Script now uses a minimum visitors threshold
*        per Ad instead of AdGroup
*   - Added the ability to add the start date as a label to AdGroups
@ianlewis
ianlewis / csv_import_magic.js
Last active February 3, 2023 13:16
A Google Apps Script for importing CSV data into a Google Spreadsheet.
// vim: ft=javascript:
/*jslint sloppy: true, vars: true, white: true, nomen: true, browser: true */
/*global SpreadsheetApp, UiApp, UrlFetchApp, Utilities */
/*
* A script to automate requesting data from an external url that outputs CSV data.
*
* Adapted from the Google Analytics Report Automation (magic) script.
* @author nickski15@gmail.com (Nick Mihailovski)
* @author ianmlewis@gmail.com (Ian Lewis)
*/
bootstrap.list <- c("car",
"codetools",
"colorspace",
"data.table",
"devtools",
"dplyr",
"forecast",
"ggplot2",
"knitr",
"lattice",
@mderazon
mderazon / export-to-csv.gs
Last active April 2, 2024 22:25
Google apps script to export to individual csv files all sheets in an open spreadsheet
/*
* script to export data in all sheets in the current spreadsheet as individual csv files
* files will be named according to the name of the sheet
* author: Michael Derazon
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var csvMenuEntries = [{name: "export as csv files", functionName: "saveAsCSV"}];
ss.addMenu("csv", csvMenuEntries);
@russorat
russorat / mcc-account-reporting.js
Created April 5, 2014 00:50
This script will run through all your AdWords accounts and store your data in a Google Spreadsheet.
/********************************************************************************
* This script will run through all your AdWords accounts and store your data in
* a Google Spreadsheet.
*
* @author Russell Savage <russellsavage@gmail.com>
* @version 1.0
*
* THIS SOFTWARE IS PROVIDED BY Russell Savage ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@dsparks
dsparks / Custom font in ggplot2.R
Last active June 27, 2017 13:20
Load, then use any font on the system
require(extrafont)
require(ggplot2)
font_import(pattern = "GIL", prompt = FALSE) # Import Gill family
loadfonts(device="win") # Load them all
fonts() # See what fonts are available
zp1 <- ggplot(data = iris,
aes(x = Sepal.Length, y = Sepal.Width, label = Species))
zp1 <- zp1 + geom_text(family = "Gill Sans MT")
zp1 <- zp1 + theme(text=element_text(family="Gill Sans Ultra Bold"))
@dsparks
dsparks / colors.R
Last active December 23, 2020 22:12
Sunlight Foundation palettes, based on the Wes Anderson code
# Sunlight Foundation style guide: http://design.sunlightlabs.com/projects/Sunlight-StyleGuide-DataViz.pdf
# Ram's original Wes Anderson code: https://github.com/karthik/wesanderson/blob/master/R/colors.R
#' A Wes Anderson palette generator
#'
#' These are a handful of color palettes from Wes Anderson movies.
#' @param n Number of colors desired. Unfortunately most palettes now only have 4 or 5 colors. But hopefully we'll add more palettes soon. All color schemes are derived from the most excellent Tumblr blog: \href{http://wesandersonpalettes.tumblr.com/}{Wes Anderson Palettes}
#' @param name Name of desired palette. Choices are: \code{GrandBudapest}, \code{Moonrise1}, \code{Royal1}, \code{Moonrise2}, \code{Cavalcanti}, \code{Royal2}, \code{GrandBudapest2}, \code{Moonrise3}, \code{Chevalier}, \code{BottleRocket}, \code{darjeeling}, \code{darjeeling2}
#' @param type Set to continuous if you require a gradient of colors similar to how heat map works.
#' @export
x <- c(
'knitr', # A general-purpose package for dynamic report generation in R.
# 'sqldf', # For running SQL statements on R data frames, optimized for convenience.
'randomForest', # Classification and regression based on a forest of trees using random inputs.
'arm', # R functions for processing lm, glm, svy.glm, mer and polr outputs.
'ggplot2', # An implementation of the Grammar of Graphics.
'gridExtra', # misc. high-level Grid functions
'plyr', # Tools for splitting, applying and combining data.
'tree', # Classification and regression trees.
'gbm', # Generalized Boosted Regression Models
@MarkEdmondson1234
MarkEdmondson1234 / HWplot.R
Created June 18, 2014 21:29
A function to plot a holtWinters timeseries in ggplot2
#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 / processTweets.r
Last active August 29, 2015 14:02
A couple of functions used to process Tweets after fetching
### 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,