การ Join คำถามและคำตอบกับแท็ก
เพื่อทำความเข้าใจตาราง questions และ answers ให้ลึกขึ้น จะใช้ตาราง question_tags เพื่อดูว่าแต่ละคำถามและคำตอบมีแท็กใดบ้าง สามารถรวมตารางเหล่านี้ได้โดยใช้ inner join สองครั้ง ทั้งกับตาราง questions และตาราง answers
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การ Join ข้อมูลด้วย dplyr
คำแนะนำการฝึกหัด
- ใช้ inner join สองครั้งเพื่อรวมตาราง
question_tagsและtagsเข้ากับตารางquestions - จากนั้น ใช้ inner join สองครั้งเพื่อรวมตาราง
question_tagsและtagsเข้ากับตารางanswers
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Inner join the question_tags and tags tables with the questions table
questions %>%
inner_join(question_tags, by = ___) %>%
inner_join(tags, by = ___)
# Inner join the question_tags and tags tables with the answers table
answers %>%
___ %>%
___