开始使用免费开始使用

连接问题与回答计数

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