合併問題與解答數
我們也能判斷實際上有多少問題得到了解答。只要為每個問題計算解答數量,接著就能把這些解答次數與 questions 資料表做連接。
本練習屬於課程
使用 dplyr 進行資料表連接
練習說明
- 對
answers資料表中的question_id欄位進行計數並排序,建立answer_counts資料表。 - 將
questions資料表與answer_counts資料表連接,並保留questions中的所有觀測值。 - 將
n欄位中的 NA 值替換為 0。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Count and sort the question id column in the answers table
answer_counts <- answers %>%
___
# Combine the answer_counts and questions tables
questions %>%
___ %>%
# Replace the NAs in the n column
___