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

Setting effects codes

In this exercise, we will change the chocolate data frame so that the contrasts for the factors Brand and Type are set to effects codes. The chocolate data is already loaded and I've written the code to change the Brand factor. Your job is to copy that code and modify it for the Type variable.

Bu egzersiz

Choice Modeling for Marketing in R

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

Egzersiz talimatları

  • Copy the three lines of code I've written to change the contrasts for the Brand variable.
  • Change chocolate$Brand to chocolate$Type in the copied code.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# set the contrasts for Brand to effects code
contrasts(chocolate$Brand) <- contr.sum(levels(chocolate$Brand))
dimnames(contrasts(chocolate$Brand))[[2]] <- levels(chocolate$Brand)[1:4]
contrasts(chocolate$Brand)

# set the contrasts for Type to effects code
Kodu Düzenle ve Çalıştır