-
-
Save dgkeyes/d8832ba32d5db9ed960992b0963c2d12 to your computer and use it in GitHub Desktop.
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
library(tidyverse) | |
library(readxl) | |
library(janitor) | |
library(unheadr) | |
survey_monkey_raw <- read_excel("data/survey-monkey-data.xlsx") %>% | |
mash_colnames(1) %>% | |
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)") | |
survey_monkey_long <- survey_monkey_raw %>% | |
pivot_longer(select_all_the_things_youve_done_in_the_past_24hours_slept:last_col()) %>% | |
mutate(value = str_remove(value, "- ")) | |
survey_monkey_tidy <- survey_monkey_long %>% | |
mutate(response_label = case_when( | |
value %in% fixed_responses ~ value, | |
is.na(value) ~ NA_character_, | |
TRUE ~ "Other" | |
)) %>% | |
select(start_date, response_label) %>% | |
drop_na(response_label) | |
survey_monkey_tidy %>% | |
count(response_label) %>% | |
ggplot(aes(x = n, | |
y = response_label)) + | |
geom_col() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment