Skip to content

Instantly share code, notes, and snippets.

@dgkeyes
Created May 13, 2022 22:55
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 dgkeyes/009a4ba5201a00023d41fc4fe8d38f72 to your computer and use it in GitHub Desktop.
Save dgkeyes/009a4ba5201a00023d41fc4fe8d38f72 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(readxl)
library(janitor)
google_forms_raw <- read_excel("data/google-forms-data.xlsx") %>%
clean_names()
fixed_responses <- c("Slept", "Eaten food", "Cooked food", "Gone to work", "Commuted for work", "Relaxed with a hobby (TELL US THE HOBBY BY TYPING IN THE OTHER FIELD)")
google_forms_tidy <- google_forms_raw %>%
separate_rows(select_all_the_things_youve_done_in_the_past_24hours,
sep = ", ") %>%
mutate(things_done_in_last_24hours = case_when(
select_all_the_things_youve_done_in_the_past_24hours %in% fixed_responses ~ select_all_the_things_youve_done_in_the_past_24hours,
TRUE ~ "Other"
))
google_forms_tidy %>%
count(things_done_in_last_24hours) %>%
ggplot(aes(x = n,
y = things_done_in_last_24hours)) +
geom_col()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment