비슷한 열 묶기와 형태 변환
이 레슨에서는 Kaggle 데이터 과학 설문 데이터셋에서 서로 연관된 열이 어떻게 묶여 있는지 살펴봤어요. 예를 들어, 여러 업무상의 어려움 빈도를 다루는 열들이 있었죠. 이런 변수들은 보통 함께 살펴보는 것이 좋지만, 먼저 해당 열들을 찾아서 활용하기 쉬운 형태로 바꿔야 합니다. 이번에는 응답자들이 학습용 플랫폼을 얼마나 유용하다고 느꼈는지에 관한 질문을 가지고 그 과정을 연습해 볼게요.
데이터셋 multiple_choice_responses는 미리 로드되어 있어요.
이 연습은 강의의 일부입니다
Tidyverse로 배우는 범주형 데이터
연습 안내
- 이름에
"LearningPlatformUsefulness"가 포함된 열만 선택하세요. - 데이터를 넓은 형식에서 긴 형식으로 바꾸고, 열 이름은
learning_platform와usefulness로 하세요. usefulness가 NA인 행을 제거하세요.learning_platform의 각 문자열에서"LearningPlatformUsefulness"를 제거하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
learning_platform_usefulness <- multiple_choice_responses %>%
# Select columns with LearningPlatformUsefulness in title
___(___("LearningPlatformUsefulness")) %>%
# Change data from wide to long
___(everything(), names_to = "learning_platform", values_to = "usefulness") %>%
# Remove rows where usefulness is NA
___(___()) %>%
# Remove "LearningPlatformUsefulness" from each string in learning_platform
mutate(learning_platform = ___())