開始使用免費開始

合併問題與解答數

我們也能判斷實際上有多少問題得到了解答。只要為每個問題計算解答數量,接著就能把這些解答次數與 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
  ___
編輯並執行程式碼