Created
December 23, 2019 10:13
-
-
Save Stan125/55166ea0f67309eb0ca482ebe0ac5172 to your computer and use it in GitHub Desktop.
Script to reproduce https://www.reddit.com/r/dataisbeautiful/comments/eeisbm/number_of_inedible_jalapeño_stems_in_20_subway/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Stems Count in Los Angeles Subway Sandwiches ## | |
## taken from video - https://www.youtube.com/watch?v=4vtbkW4-9EY | |
# Libraries | |
library("ggplot2") | |
# Data | |
stem_count <- c(2, 0, 1, 3, 4, 5, 2, 1, 4, 4, 1, 6, 2, 1, 2, 3, 3, 2, 4, 3) | |
stem_data <- data.frame(stem_co = stem_count, | |
sandwich = seq_len(length(stem_count))) | |
# Visualization | |
p <- ggplot(stem_data, aes(x = sandwich, y = stem_co)) + | |
geom_bar(stat = "identity", size = 3) + | |
geom_hline(yintercept = mean(stem_data$stem_co), | |
col = "red") + | |
scale_y_continuous(breaks = seq(1, 6)) + | |
theme_bw() + | |
labs(x = "Sandwich #", y = "Number of stems", | |
title = "Number of Jalapeño Stems in each Subway Sandwich", | |
subtitle = paste0("Mean Stems: ", round(mean(stem_data$stem_co), 2), | |
", Source: Gus Johnson")) | |
ggsave(p, file = "plot_gus.png", width = 5, height = 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment