Manually collapsing levels
There are 16 job titles (including "Other") that people could select in the survey. Let's collapse those into a couple big categories: "Computer Scientist", "Data analyst/scientist/engineer", "Researcher," and "Other." The dataset multiple_choice_responses
has been loaded for you.
This exercise is part of the course
Categorical Data in the Tidyverse
Exercise instructions
- Collapse the levels of
CurrentJobTitleSelect
into a new variable,grouped_titles
. - Then take
grouped_titles
and put everything that isn't one of those three grouped titles into "Other Title". - Finally, get the count of all the grouped titles.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
multiple_choice_responses %>%
# Create new variable, grouped_titles, by collapsing levels in CurrentJobTitleSelect
___(grouped_titles = ___(CurrentJobTitleSelect,
"Computer Scientist" = c("Programmer", "Software Developer/Software Engineer"),
"Researcher" = "Scientist/Researcher",
"Data Analyst/Scientist/Engineer" = c("DBA/Database Engineer", "Data Scientist",
"Business Analyst", "Data Analyst",
"Data Miner", "Predictive Modeler"))) %>%
# Keep all the new titles and turn every other title into "Other"
___(grouped_titles = ___(grouped_titles,
___ = c("Computer Scientist",
"Researcher",
"Data Analyst/Scientist/Engineer"))) %>%
# Get a count of the grouped titles
___(___)