Get startedGet started for free

Aggregating each theme

Previously, you combined tables to compare themes. Before doing this comparison, you'll want to aggregate the data to learn more about the pieces that are a part of each theme, as well as the colors of those pieces.

The table you created previously has been preloaded for you as inventory_sets_themes. It was filtered for each theme, and the objects have been saved as batman and star_wars.

inventory_sets_themes <- inventory_parts_joined %>%
  inner_join(sets, by = "set_num") %>%
  inner_join(themes, by = c("theme_id" = "id"), suffix = c("_set", "_theme"))

batman <- inventory_sets_themes %>%
  filter(name_theme == "Batman")

star_wars <- inventory_sets_themes %>%
  filter(name_theme == "Star Wars")

This exercise is part of the course

Joining Data with dplyr

View Course

Exercise instructions

  • Count the part number and color id for the parts in Batman and Star Wars, weighted by quantity.

Hands-on interactive exercise

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

# Count the part number and color id, weight by quantity
batman %>%
  ___

star_wars %>%
  ___
Edit and Run Code