Get startedGet started for free

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.

This exercise is part of the course

Joining Data with dplyr

View Course

Exercise instructions

  • 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

sets %>%
  # Add inventories using an inner join 
  ___ %>%
  # Add inventory_parts using an inner join 
  ___
Edit and Run Code