Aan de slagGa gratis aan de slag

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

Deze oefening maakt deel uit van de cursus

Joining Data with dplyr

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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

star_wars %>%
  ___
Code bewerken en uitvoeren