Skip to content

Instantly share code, notes, and snippets.

@founddrama
Created August 24, 2019 15:40
Show Gist options
  • Save founddrama/682e26f2530b7a825325465db9e3b744 to your computer and use it in GitHub Desktop.
Save founddrama/682e26f2530b7a825325465db9e3b744 to your computer and use it in GitHub Desktop.
"Homebrew Competition Analysis" w/r/t/ my own homebrew competition data, in Rstudio and with some tidyverse tools.
---
title: "Homebrew Competition Analysis"
author: "Rob Friesel"
date: "10/28/2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library("dplyr")
library("ggplot2")
setwd("~")
#
# COMPETITION DATA
#
comp.data <- read.csv("https://docs.google.com/spreadsheets/d/132U3k7xGZESm77twev5ULAzt28rbyrLLWb9n-oo8MzQ/gviz/tq?tqx=out:csv&sheet=Sheet1") %>%
# remove extraneous columns
select_if(~!all(is.na(.))) %>%
# fix date columns
mutate_at(vars(ends_with("Date")), ~as.Date(., format="%m/%d/%Y")) %>%
# Awards as factors
mutate_at(vars(Award), as.factor)
```
```{r}
ggplot(comp.data, aes(Package.to.Comp, Score)) +
geom_point() +
geom_smooth(method = "lm") +
xlab("Days from Packaging to Competition") +
ylab("Competition Score")
ggplot(comp.data, aes(Award, Package.to.Comp)) +
geom_boxplot()
```
```{r noonan.2019}
noonan.2019 <- read.csv("https://docs.google.com/spreadsheets/d/1c3CZXL4_QrTn-HmuPC1xcNwD-fFRPnR-upxcCBplZXg/gviz/tq?tqx=out:csv&sheet=Sheet1") %>%
# remove extraneous columns
select_if(~!all(is.na(.))) %>%
# fix date columns
mutate_at(vars(ends_with("Date")), ~as.Date(., format="%m/%d/%Y")) %>%
# fix Range factors
mutate_at(vars(Predicted.Range),
~factor(., levels=c("Problematic", "Fair", "Good",
"Very Good", "Excellent", "Outstanding")))
ggplot(noonan.2019, aes(x=DELTA)) +
geom_histogram()
ggplot(noonan.2019, aes(x=Predicted.Score, y=Score)) +
geom_point(aes(color=Predicted.Range)) +
geom_smooth(method = "glm") +
annotate("text", label = -noonan.2019$DELTA, hjust = 0, size = 3,
x = noonan.2019$Predicted.Score + 0.25, y = noonan.2019$Score) +
xlab("Predicted Score") + ylab("Actual Score") +
theme(legend.position = "bottom") + labs(color = "Predicted Range")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment