Agregarea fiecărei teme
Anterior, ai combinat tabele pentru a compara teme. Înainte de a face această comparație, vei agrega datele pentru a afla mai multe despre piesele din fiecare temă, precum și culorile acestora.
Tabelul creat anterior a fost preîncărcat pentru tine ca inventory_sets_themes. Acesta a fost filtrat pentru fiecare temă, iar obiectele au fost salvate ca batman și 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")
Acest exercițiu face parte din cursul
Joining Data with dplyr
Instrucțiuni pentru exercițiu
- Numără numărul piesei și id-ul culorii pentru piesele din Batman și Star Wars, ponderat după cantitate.
Exercițiu interactiv practic
Încearcă acest exercițiu completând acest cod de exemplu.
# Count the part number and color id, weight by quantity
batman %>%
___
star_wars %>%
___