BaşlayınÜcretsiz başlayın

Sort the long data

Okay, we've got the choice data into long format in chocolate, but there are a couple things to do to tidy up. First, it would be nice to sort chocolate so that the alternatives for the same choice question appear together.

Bu egzersiz, kursun bir parçasıdır

Choice Modeling for Marketing in R

Kursa Göz Atın

Egzersiz talimatları

  • Fill in the variables that you want to sort by in the order() function. First chocolate$Subject, then chocolate$Trial, then chocolate$Alt.
  • Sort the rows in the chocolate data frame using new_order.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# 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)
Kodu Düzenle ve Çalıştır