LoslegenKostenlos loslegen

Grouping and reshaping similar columns

In this lesson, we saw how some of the columns in the Kaggle data science survey dataset were tied together, such as columns each addressing the frequency of different work challenges. We usually want to look at those variables together, but first, we need to find them and change them into a format that's easier to use. Let's try the process out with the questions around how useful the survey respondents found different platforms for learning.

The dataset multiple_choice_responses has been loaded for you.

Diese Übung ist Teil des Kurses

Categorical Data in the Tidyverse

Kurs anzeigen

Anleitung zur Übung

  • Select only the columns with "LearningPlatformUsefulness" in the name.
  • Change the data from wide to long format with two columns, learning_platform and usefulness.
  • Remove rows where usefulness is NA.
  • Remove "LearningPlatformUsefulness" from each string in learning_platform.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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 = ___())
Code bearbeiten und ausführen