1. 学习
  2. /
  3. 项目
  4. /
  5. 사례 연구: R로 하는 탐색적 데이터 분석

Connected

练习

주제 값 다시 부호화하기

해석을 더 쉽게 하기 위해 데이터 정리를 한 단계 더 진행하겠습니다. 현재 주제는 두 글자 코드로 표시되어 있습니다:

  1. me: Palestinian conflict
  2. nu: Nuclear weapons and nuclear material
  3. di: Arms control and disarmament
  4. hr: Human rights
  5. co: Colonialism
  6. ec: Economic development

데이터를 더 쉽게 해석할 수 있도록, 이 코드를 전체 이름으로 바꾸어 다시 부호화(recode)하세요. 이를 위해 dplyr의 recode() 함수를 사용할 수 있으며, 이 함수는 지정한 값으로 대체해 줍니다:

example <- c("apple", "banana", "apple", "orange")
recode(example,
       apple = "plum",
       banana = "grape")

说明

100 XP

dplyr의 recode() 함수를 mutate() 안에서 사용하여, votes_gathered 데이터 프레임에 있는 각 두 글자 코드를 해당 전체 이름으로 바꾸세요. 결과를 votes_tidied로 저장하세요.