1. Learn
  2. /
  3. Courses
  4. /
  5. Joining Data with dplyr

Connected

Exercise

Combining sets

The data you aggregated in the last exercise has been preloaded for you as batman_colors and star_wars_colors. Prior to visualizing the data, you'll want to combine these tables to be able to directly compare the themes' colors.

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

Instructions 1/2

undefined XP
    1
    2
  • Join the batman_colors and star_wars_colors tables; be sure to include all observations from both tables.
  • Replace the NAs in the total_batman and total_star_wars columns.