Skip to content

Instantly share code, notes, and snippets.

@jrosen48
Last active July 20, 2020 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrosen48/b5ade624f057993a75b7ddb556c6525d to your computer and use it in GitHub Desktop.
Save jrosen48/b5ade624f057993a75b7ddb556c6525d to your computer and use it in GitHub Desktop.
library(tidyverse)
library(tidytuesdayR)
library(janitor)
tt_output <- tt_load_gh(last_tuesday())
list_of_d <- tt_download(tt_output)
d <- list_of_d$animal_complaints
d %>%
clean_names() %>%
mutate(animal_type = tools::toTitleCase(animal_type)) %>%
count(animal_type, complaint_type) %>%
spread(complaint_type, n, fill = 0) %>%
gather(complaint_type, n, -animal_type) %>%
ggplot(aes(fill = animal_type, y = n, x = reorder(complaint_type, n))) +
geom_col(positio = "dodge") +
hrbrthemes::theme_ipsum() +
scale_fill_brewer("", type = "qual") +
xlab(NULL) +
ylab(NULL) +
ggtitle("What Animals do Brisbane, Australia Residents Complaint About?")
ggsave("animal-complaints.png", width = 8, height = 6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment