トピックのリコード
より解釈しやすくするために、データクリーニングをもう一段進めます。現在、トピックは2文字のコードで表されています。
- me: Palestinian conflict
- nu: Nuclear weapons and nuclear material
- di: Arms control and disarmament
- hr: Human rights
- co: Colonialism
- ec: Economic development
データを読み取りやすくするため、これらのコードをフルネームに置き換えてリコードしましょう。これは dplyr の recode() 関数で行えます。指定した値に置き換えます。
example <- c("apple", "banana", "apple", "orange")
recode(example,
apple = "plum",
banana = "grape")
この演習はコースの一部です
ケーススタディ:Rで行う探索的データ分析
演習の手順
dplyr の recode() を mutate() の中で使い、データフレーム votes_gathered にある各2文字コードを対応するフルネームに置き換えてください。votes_tidied として保存します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Replace the two-letter codes in topic: votes_tidied
votes_tidied <- ___ %>%
mutate(topic = recode(___,
___ = "Palestinian conflict",
___ = "Nuclear weapons and nuclear material",
___ = "Arms control and disarmament",
___ = "Human rights",
___ = "Colonialism",
___ = "Economic development"))