수준 직접 합치기
설문에서 응답자가 선택할 수 있었던 직함은 총 16개(“Other” 포함)예요. 이를 몇 가지 큰 범주로 묶어 봅시다: "Computer Scientist", "Data analyst/scientist/engineer", "Researcher", 그리고 "Other". 데이터셋 multiple_choice_responses는 미리 로드되어 있어요.
이 연습은 강의의 일부입니다
Tidyverse로 배우는 범주형 데이터
연습 안내
CurrentJobTitleSelect의 수준을 새 변수grouped_titles로 합치세요.- 그런 다음
grouped_titles에서 위 세 가지로 묶인 직함이 아닌 것은 모두 "Other Title"로 분류하세요. - 마지막으로, 묶인 모든 직함의 개수를 구하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
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
___(___)