시작하기무료로 시작하기

세트 결합하기

이전 연습 문제에서 집계한 데이터가 batman_colorsstar_wars_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))

이 연습은 강의의 일부입니다

dplyr로 데이터 결합하기

강의 보기

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

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")) 
코드 편집 및 실행