StatPREP Hex Sticker

This document contains the code to make the sticker for STA 199: Intro to Data Science. The following packages are used in this project:

library(hexSticker)
library(readr)
library(tidyverse)
library(tibble)
library(showtext)
library(nnet)
library(knitr)

The Data

The data is the Capital Bikeshare data set pulled from the UCI Machine Learning Repository. The following variables are used in this project:

  • season: 1 - Winter, 2 - Spring, 3 - Summer 4 - Fall
  • atemp: feeling temperature รท 50 (in degrees Celsius)
bikeshare <- read_csv("https://raw.githubusercontent.com/matackett/data/master/capital-bikeshare.csv")    
bikeshare <- bikeshare %>%
  mutate(season = case_when(
    season==1 ~ "Winter",
    season==2 ~ "Spring",
    season==3 ~ "Summer",
    season==4 ~ "Fall"
  )) %>% 
  select(season,cnt,atemp)

Density Plot

A multinomial logistic regression model is used to create the main plot. The response variable is season and the predictor variable is atemp.

p <- ggplot(data=bikeshare,aes(x=cnt,y = atemp, color = season)) +
  geom_point(alpha=0.37) +
  scale_fill_manual( values = c("#F8766D","#7CAE00","#C77CFF","#00BFC4")) +
  theme_void() +
  theme(legend.position="none") +
  geom_text(x = 4500, y = .15, label  = "Centering stat ed\non data.", color = "black") +
  geom_text(x = 4500, y = .65, label = "MAA : ASA : AMATYC", color = "#FFFFFF80")

Make Sticker

# add font to be used in sticker function
font_add_google("Open Sans", "open")
# create and save sticker
sticker(p, package="StatPREP",p_color="#7A4183", p_family="open", p_size=9.5, p_y=1.0, s_x=1, s_y=1.1, s_width=1.5, s_height=1.5, h_color="#7A4183", h_size =0.8, h_fill = "#D080F080", filename="../../static/images/statprep_sticker.png")