Skip to content

Instantly share code, notes, and snippets.

@Stan125
Created December 23, 2019 10:13
Show Gist options
  • Save Stan125/55166ea0f67309eb0ca482ebe0ac5172 to your computer and use it in GitHub Desktop.
Save Stan125/55166ea0f67309eb0ca482ebe0ac5172 to your computer and use it in GitHub Desktop.
## 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