LoslegenKostenlos loslegen

Recoding the topics

There's one more step of data cleaning to make this more interpretable. Right now, topics are represented by two-letter codes:

  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

So that you can interpret the data more easily, recode the data to replace these codes with their full name. You can do that with dplyr's recode() function, which replaces values with ones you specify:

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

Diese Übung ist Teil des Kurses

Case Study: Exploratory Data Analysis in R

Kurs anzeigen

Anleitung zur Übung

Use the recode() function from dplyr in a mutate() to replace each two-letter code in the votes_gathered data frame with the corresponding full name. Save this as votes_tidied.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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"))
Code bearbeiten und ausführen