MulaiMulai sekarang secara gratis

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))

Latihan ini adalah bagian dari kursus

Joining Data with dplyr

Lihat Kursus

Petunjuk latihan

  • Sort the number of star wars pieces in the parts_joined table in descending order.
  • Inner join the colors table to the parts_joined table.
  • Combine the parts table to the previous join using an inner join; add "_color" and "_part" suffixes to specify whether or not the information came from the colors table or the parts table.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

parts_joined %>%
  # Sort the number of star wars pieces in descending order 
  ___ %>%
  # Join the colors table to the parts_joined table
  ___ %>%
  # Join the parts table to the previous join 
  ___
Edit dan Jalankan Kode