1. 学ぶ
  2. /
  3. コース
  4. /
  5. dplyr で行うデータの結合

Connected

演習

セットを組み合わせる

前の演習で集計したデータは、batman_colors と star_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))

指示1 / 2

undefined XP
    1
    2
  • batman_colors と star_wars_colors のテーブルを結合し、両方のテーブルのすべての観測値を含めてください。
  • total_batman 列と total_star_wars 列の NA を置き換えてください。