LoslegenKostenlos loslegen

Joining three tables

You can string together multiple joins with inner_join and the pipe (%>%), both with which you are already very familiar!

We'll now connect sets, a table that tells us about each LEGO kit, with inventories, a table that tells us the specific version of a given set, and finally to inventory_parts, a table which tells us how many of each part is available in each LEGO kit.

So if you were building a Batman LEGO set, sets would tell you the name of the set, inventories would give you IDs for each of the versions of the set, and inventory_parts would tell you how many of each part would be in each version.

Diese Übung ist Teil des Kurses

Joining Data with dplyr

Kurs anzeigen

Anleitung zur Übung

  • Combine the inventories table with the sets table.
  • Next, join the inventory_parts table to the table you created in the previous join by the inventory IDs.

Interaktive Übung

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

sets %>%
  # Add inventories using an inner join 
  ___ %>%
  # Add inventory_parts using an inner join 
  ___
Code bearbeiten und ausführen