Kombinování datových sad
Data, která jsi agregoval/a v předchozím cvičení, jsou předem načtena jako batman_colors a star_wars_colors. Než je vizualizuješ, budeš chtít tyto tabulky spojit, abys mohl/a přímo porovnat barvy jednotlivých témat.
batman_colors <- inventory_parts_themes %>%
filter(name_theme == "Batman") %>%
group_by(color_id) %>%
summarize(total = sum(quantity)) %>%
mutate(fraction = total / sum(total))
star_wars_colors <- inventory_parts_themes %>%
filter(name_theme == "Star Wars") %>%
group_by(color_id) %>%
summarize(total = sum(quantity)) %>%
mutate(fraction = total / sum(total))
Toto cvičení je součástí kurzu
Joining Data with dplyr
Interaktivní cvičení na vyzkoušení si v praxi
Vyzkoušejte si toto cvičení dokončením tohoto ukázkového kódu.
batman_colors %>%
# Join the Batman and Star Wars colors
___(star_wars_colors, by = "color_id", suffix = c("_batman", "_star_wars")) %>%
# Replace NAs in the total_batman and total_star_wars columns
___ %>%
inner_join(colors, by = c("color_id" = "id"))