Get startedGet started for free

Joining three or more tables

1. Joining three or more tables

So far you've learned to join two tables together, but the same approach can join three or more.

2. Joining sets and inventories

In the last lesson, you joined the sets table with the inventories table. Notice that the joined version keeps the theme id.

3. The themes table

What if we wanted to join the theme names, from the themes table, into this table as well?

4. Adding another join

You can pipe any number of joins together, just like you can combine other dplyr verbs. With this second join, remember that you'll have to specify that you're matching theme id to id in the themes table. That first join between sets and themes didn't need a suffix argument, because none of the variable names were duplicated. But this new join brings in a second name column.

5. Recall: suffix

So recall that you can add suffix, and specify that we want the suffixes "set" and "theme". Notice that in a series of joins, each will usually have different "by" arguments, and often they'll have different suffix arguments. This will depend on the details of the tables you're joining.

6. Joining more than three tables

In the exercises, you'll learn how to join not just three, but four tables together: sets, inventories, inventory-underscore-parts, and colors. This will let you answer questions like "what are the most common colors of parts in Lego sets?" And you'll also get accustomed to working with data that spans a large number of tables.

7. Let's practice!

Let's give it a shot!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.