Recreating plots in R: the power of tiny gains

Once in awhile I find some great charts which make me stop and think. Below is one example of this: 1% better every day is all it takes to completely change your life. pic.twitter.com/kYbgGOzzZv — Santiago (@svpino) September 10, 2021 I really appreciate the inspirational message behind it: being deliberate about the change you wish to see in the world. With that in mind, I want to recreate that chart below using the R programming language (regardless if the trajectory path is realistic or not)....

September 21, 2021 · Christopher Yee

[Updated] US firearm sales in 2020

My original exploratory analysis on the topic can be found at Firearm Sales: How are Americans coping with 2020? This post is a quick #rstats follow-up to visualize the final tally for 2020 data. Load libraries library(tidyverse) library(lubridate) library(scales) Download & parse data df_raw <- read_csv("https://raw.githubusercontent.com/BuzzFeedNews/nics-firearm-background-checks/master/data/nics-firearm-background-checks.csv") df <- df_raw df_clean <- df %>% filter(month >= "2016-01" & month < "2021-01") %>% select(month, state, handgun, long_gun) %>% arrange((month)) %>% mutate(month = as....

March 5, 2021 · Christopher Yee

Visualizing FB spend: image vs video creative

Objective: plot the comparison of total Facebook spend between image and video creatives for a small sample of DTC brands. The original piece without any visualization (e.g. tabulated data) can be found here but the main takeaway: Though it can be tempting to go all in on video assets, I intend to use this data as added inspiration to continue investing in and testing Images. Load modules import pandas as pd import numpy as np import matplotlib....

February 10, 2021 · Christopher Yee

California Wildfires: cumulative acres burned over time

Wildfires are raging across California (again). Always knew I would end up in hell but I imagined it was more of a spontaneous combustion type of event rather than a gradual descent into the infernal #everythingisfine pic.twitter.com/gl6otozX6f — Christopher Yee (@Eeysirhc) September 8, 2020 What I noticed over the years of “doom watching” is how the news only report on tabulated data. They lacked any sort of visualization to underscore the impact of these fires....

September 16, 2020 · Christopher Yee

Visualizing the relationship between quality score & CPC

The SEM industry has published a lot of information about the importance of improving quality score to lower average cost per click (CPC). Most of those articles, however, just share a table with quality score in one column and its associated % increase/decrease to average CPC in the other. Although helpful I think it misses the mark on underscoring the magnitude of how much QS can help CPC. We will do something different: the python code below will take that data and visualize the impact to average CPC for a given quality score....

August 11, 2020 · Christopher Yee

Recreating plots in R: intro to bootstrapping

Objective: recreate and visualize the 500K sampling distribtuion of means from this intro to bootstrapping in statistics post using R. Load libraries library(tidyverse) library(rsample) Download data df <- read_csv("https://statisticsbyjim.com/wp-content/uploads/2017/04/body_fat.csv") Bootstrap resampling 500K df_bs <- df %>% bootstraps(times = 500000) %>% mutate(average = map_dbl(splits, ~ mean(as.data.frame(.)$`%Fat`))) Visualize sampling distribution of means df_bs %>% ggplot(aes(average)) + geom_histogram(binwidth = 0.1, alpha = 0.75, color = 'white', fill = 'steelblue') + scale_x_continuous(limits = c(25, 32)) + scale_y_continuous(labels = scales::comma_format()) + labs(title = "Histogram of % Fat", subtitle = "500K bootstrapped samples with 92 observations in each", x = "Average Mean", y = "Frequency") + theme_minimal() ...

June 1, 2020 · Christopher Yee

Script to track COVID-19 cases in the US

A couple weeks ago I shared an #rstats script to track global coronavirus cases by country. The New York Times also released COVID-19 data for new cases in the United States, both at the state and county level. You can run the code below on a daily basis to get the most up to date figures. Feel free to modify for your own needs: library(scales) library(tidyverse) library(gghighlight) state <- read_csv("https://raw....

March 30, 2020 · Christopher Yee

[Updated] Top Industries from Inc.5000 Companies

Changelog Originally published on September 10th, 2019 Built a Shiny app for this Full code can be found on GitHub One of my favorite online marketers, (the) Glen Allsopp, tweeted the following: Over the past few weeks I've went through every site in the Inc. 5000. My mind has been blown multiple times. Don't click if you're easily distracted. Enjoy!...

January 7, 2020 · Christopher Yee