가장 흔한 수준 유지하기
때로는 비율로 수준을 유지하기보다, 가장 흔한 n개의 수준만 유지하고 싶을 때가 있어요. 비율이 아니라 개수로 유지했을 때 MLMethodNextYearSelect에서 어떤 수준이 남는지 확인해 봅시다. multiple_choice_responses는 미리 로드되어 있어요.
이 연습은 강의의 일부입니다
Tidyverse로 배우는 범주형 데이터
연습 안내
- 방법을 선택하지 않은 응답자는 제거하세요.
MLMethodNextYearSelect에서 새 변수ml_method를 만들어, 가장 흔한 제목 5개는 유지하고 나머지는other_level인수를 사용해 "other method"로 묶으세요.- 각
ml_method의 빈도를 내림차순으로 정렬해 세어 보세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
multiple_choice_responses %>%
# Remove NAs
filter(___) %>%
# Create ml_method, retaining the 5 most common methods and renaming others "other method"
mutate(ml_method = ___(MLMethodNextYearSelect, ___, other_level = ___)) %>%
# Count the frequency of your new variable, sorted in descending order
___(ml_method, ___)