ÎncepețiÎncepe gratuit

Combinarea seturilor

Datele pe care le-ai agregat în exercițiul anterior au fost preîncărcate ca batman_colors și star_wars_colors. Înainte de a vizualiza datele, va trebui să combini aceste tabele pentru a putea compara direct culorile celor două teme.

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

Acest exercițiu face parte din cursul

Joining Data with dplyr

Vezi cursul

Exercițiu interactiv practic

Încearcă acest exercițiu completând acest cod de exemplu.

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")) 
Editează și rulează codul