Get startedGet started for free

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

This exercise is part of the course

Joining Data with dplyr

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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")) 
Edit and Run Code