開始使用免費開始

大家選了什麼?

在建立模型之前,我們想先了解,人在不同產品屬性下會怎麼選。最好的做法是計算具有特定特徵的車被選中的次數。在這個練習中,我們聚焦在變速箱這個特徵,並用 xtabs() 函式來統計手排與自排被選中的次數。

本練習屬於課程

R 的行銷選擇模型

檢視課程

練習說明

  • 將 xtabs() 函式中的公式改成 choice ~ trans,也就是「對 trans 變數的每個層級,加總 choice 變數」。
  • 在主控台輸入名稱,列印 chosen_by_trans 表格。手排與自排的車分別被選了幾次?
  • 使用 barplot() 函式繪製 chosen_by_trans 物件。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Create a table of chosen sportscars by transmission type
chosen_by_trans <- xtabs(___, data = sportscar)

# Print the chosen_by_trans table to the console


# Plot the chosen_by_trans object
barplot(___)
編輯並執行程式碼