I hereby claim:
- I am plaudenslager on github.
- I am peterl (https://keybase.io/peterl) on keybase.
- I have a public key whose fingerprint is 49F8 140B F2A9 7183 480A 8AA8 1D66 F371 9A26 033D
To claim this, I am signing this object:
library(dplyr) | |
# raw_data is a dataframe; probably imported from CSV or other file | |
# clean_data is the dataframe we intend to use in the analysis | |
# Signup.Date is a string that contains the date - in this case the format is "mm/dd/yyyy" | |
clean_data <- mutate(raw_data, Signup.Date = as.Date(Signup.Date, "%m/%d/%y")) |
# Load dataset | |
setwd("~/Dropbox/work") | |
raw_data <- read.csv("2016-05-11 Trial Download Detail.csv", stringsAsFactors = FALSE) | |
str(raw_data) | |
head(raw_data) | |
tail(raw_data) |
fiscal_Qtr <- function(date, first_month_in_FY=4){ | |
month = as.numeric(format(date, "%m")) | |
year = as.numeric(format(date, "%y")) | |
if (month < first_month_in_FY){ | |
fiscal_year = year | |
quarter = (13 - first_month_in_FY + month-1) %/% 3 + 1 | |
}else{ | |
fiscal_year = year + 1 | |
quarter = (month - first_month_in_FY) %/% 3 + 1 | |
} |
expanded_stl <- function(ts_data, sales_data, dates){ | |
# requires ts data, plus the raw sales data and dates vectors | |
# returns a data.frame suitable for plotting with stl_plotter | |
data.stl <- stl(ts_data, s.window = 11, t.jump = 1) | |
ggdata <- data.frame(data.stl$time.series) | |
ggdata$sales <- sales_data | |
ggdata$Date <- dates | |
#ggmac.stl$Product <- "Mac" | |
return(ggdata) |
stl_plotter <- function(title, data){ | |
# requires dataframe from expanded_stl | |
# plots graphics to files | |
theme_set(theme_minimal()) | |
p <- ggplot(data, aes(x=Date, y=sales)) | |
p1 <- p + geom_line() + ylab("Data") | |
p <- ggplot(data, aes(x=Date, y=trend)) |
##' Color-blind friendly palette | |
##' From \url{http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/} | |
##' @title Color-blind friendly palette | |
##' @param palette Choose "cb", "rcb", or "bly". cb is the Winston | |
##' Chang color blind palette; rcb is that palette in reverse; bly | |
##' puts the yellow and blue in the palette first. | |
##' @return Variations on an eight-color color-blind friendly palette. | |
##' @author Winston Chang / Kieran Healy | |
##' @export | |
my.colors <- function(palette="cb"){ |
I hereby claim:
To claim this, I am signing this object: