Session Ready
Exercise

Comparing Batman and Star Wars LEGO parts

The table you created in the last exercise includes the part number of each piece, the color id, and the number of each piece in the Star Wars and Batman themes. However, we have more information about each of these parts that we can gain by combining this table with some of the information we have in other tables. Before we compare the themes, let's ensure that we have enough information to make our findings more interpretable. The table from the last exercise has been saved as parts_joined and is preloaded for you.

parts_joined <- batman_parts %>%
  full_join(star_wars_parts, by = c("part_num", "color_id"), suffix = c("_batman", "_star_wars")) %>%
  replace_na(list(n_batman = 0, n_star_wars = 0))
Instructions
100 XP
  • Sort the number of star wars pieces in the parts_joined table in descending order.
  • Join the colors table to the parts_joined table.
  • Combine the parts table to the previous join; add "_color" and "_part" suffixes to specify whether or not the information came from the colors table or the parts table.