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

Change the Selection variable

The last step in converting our data to long format is changing the Selection column where the choice is stored. In the wide format data, the choice is stored as an integer indicating which alternative was chosen. In long format it should be a logical or 0-1 variable indicating which alternative was chosen.

Bu egzersiz

Choice Modeling for Marketing in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use head() to look at the Selection variable where the choice is contained. Notice that Selection contains an integer for the number of the chosen alternative.
  • Assign chocolate$Alt == chocolate$Selection to chocolate$Selection.
  • Use head() to see how the Selection variable has been transformed.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Use head(chocolate) and look at the Selection variable. 


# Transform the Selection variable to a logical indicator
chocolate$Selection <- 

# Use head(chocolate) to see how the Selection variable has changed. Now it is logical.
Kodu Düzenle ve Çalıştır