Joining themes to their children
Tables can be joined to themselves!
In the themes
table, which is available for you to inspect in the console, you'll notice there is both an id
column and a parent_id
column. Keeping that in mind, you can join the themes
table to itself to determine the parent-child relationships that exist for different themes.
In the videos, you saw themes joined to their own parents. In this exercise, you'll try a similar approach of joining themes to their own children, which is similar but reversed. Let's try this out to discover what children the theme "Harry Potter"
has.
This exercise is part of the course
Joining Data with dplyr
Exercise instructions
- Inner join
themes
to their own children, resulting in the suffixes"_parent"
and"_child"
, respectively. - Filter this table to find the children of the
"Harry Potter"
theme.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
themes %>%
# Inner join the themes table
___ %>%
# Filter for the "Harry Potter" parent name
___