เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

การรวมชุดข้อมูล

ข้อมูลที่รวบรวมไว้ในแบบฝึกหัดก่อนหน้าถูกโหลดไว้ให้แล้วในชื่อ 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))

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การ Join ข้อมูลด้วย 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")) 
แก้ไขและรันโค้ด