Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save charliejhadley/33869e9eb646bf49c9b06e5ec0ab7181 to your computer and use it in GitHub Desktop.
Save charliejhadley/33869e9eb646bf49c9b06e5ec0ab7181 to your computer and use it in GitHub Desktop.
live-session-code_survey-monkey.R
library(tidyverse)
library(readxl)
library(janitor)
survey_monkey_raw <- read_excel("data/survey-monkey-data.xlsx") %>%
clean_names()
survey_monkey_data <- survey_monkey_raw %>%
slice(-1) %>%
mutate(respondent_id = row_number()) %>%
relocate(respondent_id) %>%
select(-start_date)
survey_monkey_clean <- survey_monkey_data %>%
mutate(other = case_when(
is.na(x8) ~ NA_character_,
TRUE ~ "Other (WHAT'S YOUR HOBBY?)"
))
survey_monkey_clean %>%
filter(is.na(x7),
!is.na(x8))
survey_monkey_tidy <- survey_monkey_clean %>%
mutate(other = case_when(
is.na(x8) ~ NA_character_,
TRUE ~ "Other (WHAT'S YOUR HOBBY?)"
)) %>%
select(respondent_id, x8, everything()) %>%
pivot_longer(select_all_the_things_youve_done_in_the_past_24hours:other)
survey_monkey_tidy %>%
count(value)
survey_monkey_data %>%
pivot_longer(select_all_the_things_youve_done_in_the_past_24hours:x7) %>%
mutate(value = str_remove(value, "- ")) %>%
count(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment