1. 학습
  2. /
  3. 강의
  4. /
  5. dplyr로 데이터 결합하기

Connected

연습 문제

차이 시각화: Batman과 Star Wars

이전 연습 문제에서 colors_joined를 만들었어요. 이제 각 색(name)에 대해 막대 하나씩, 비율 차이를 보여주는 막대 그래프를 만들어 볼 거예요.

요인(factor)과 시각화 내용은 이 강의 범위를 벗어나므로, 일부 전처리는 미리 해 두었습니다. 아래 코드는 영상에서 사용할 colors_joined 테이블을 만드는 데 사용된 코드예요.

colors_joined <- batman_colors %>%
  full_join(star_wars_colors, by = "color_id", suffix = c("_batman", "_star_wars")) %>%
  replace_na(list(total_batman = 0, total_star_wars = 0)) %>%
  inner_join(colors, by = c("color_id" = "id")) %>%
  mutate(difference = fraction_batman - fraction_star_wars,
         total = total_batman + total_star_wars) %>%
  filter(total >= 200) %>%
  mutate(name = fct_reorder(name, difference)) 

지침

100 XP
  • colors_joined 테이블을 사용해 Batman과 Star Wars 테마에서 두드러지는 색을 보여주는 막대 그래프를 만들고, 막대의 색은 각 name으로 지정하세요.