开始使用免费开始使用

对长表数据排序

好的,chocolate 数据已经整理为长表格式,但还有几件事需要清理。首先,最好给 chocolate 排序,这样同一题的各个可选项可以排在一起。

本练习是课程的一部分

R 中的营销选择建模

查看课程

练习说明

  • order() 函数中填入要排序的变量。先是 chocolate$Subject,再是 chocolate$Trial,然后是 chocolate$Alt
  • 使用 new_orderchocolate 数据框的行进行排序。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Create the new order for the chocolate data frame
new_order <- order(____, ____, ____)

# Reorder the chocolate data frame to the new_order
chocolate <- chocolate[____,]

# Look at the head() of chocolate to see how it has been reordered
head(chocolate)
编辑并运行代码