连接问题与回答计数
我们还可以计算有多少问题实际得到了回答。若对每个问题的回答数进行计数,就可以将回答计数表与 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
___