1. सीखें
  2. /
  3. पाठ्यक्रम
  4. /
  5. dplyr로 데이터 결합하기

Connected

अभ्यास

집계를 통해 세트 간 차이 살펴보기

두 개의 개별 세트와, 그 세트를 구성하는 LEGO 부품 유형을 비교하려면 데이터를 각 테마별로 집계해야 해요. 또한 영상에서 본 것처럼, 부품 개수만 보지 않고 각 세트에서 특정 부품이 차지하는 비율을 이해할 수 있도록 열을 하나 추가하겠습니다.

inventory_parts_themes 테이블이 미리 로드되어 있어요.

inventory_parts_themes <- inventories %>%
  inner_join(inventory_parts, by = c("id" = "inventory_id")) %>%
  arrange(desc(quantity)) %>%
  select(-id, -version) %>%
  inner_join(sets, by = "set_num") %>%
  inner_join(themes, by = c("theme_id" = "id"), suffix = c("_set", "_theme"))

निर्देश

100 XP
  • "Batman" 테마로 필터링해 batman_colors 객체를 만드세요.
  • batman_colors에 fraction 열을 추가해, total을 total의 합으로 나눈 값을 표시하세요.
  • 같은 단계를 반복해 "Star Wars" 세트 데이터를 필터링·집계하여 star_wars_colors 객체를 만드세요.
  • star_wars_colors에도 fraction 열을 추가해 total 대비 비율을 표시하세요.