对长表数据排序
好的,chocolate 数据已经整理为长表格式,但还有几件事需要清理。首先,最好给 chocolate 排序,这样同一题的各个可选项可以排在一起。
本练习是课程的一部分
R 中的营销选择建模
练习说明
- 在
order()函数中填入要排序的变量。先是chocolate$Subject,再是chocolate$Trial,然后是chocolate$Alt。 - 使用
new_order对chocolate数据框的行进行排序。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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)