將資料表與自己做 left join
到目前為止,你一直在把資料表和自己做 inner join,來找出像是 "Harry Potter" 或 "The Lord of the Rings" 這類主題的子主題。
但是有些主題可能完全沒有任何子主題,因此在 inner join 中不會被包含。正如你在本章所學,你可以用 left_join 搭配 filter() 來找出這些主題。
本練習屬於課程
使用 dplyr 進行資料表連接
練習說明
- 將 themes 資料表與它自己的子主題做 left join,並分別使用後綴
_parent與_child。 - 將連接結果過濾,找出沒有子主題的主題。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
themes %>%
# Left join the themes table to its own children
___ %>%
# Filter for themes that have no child themes
filter(___)