Plot shares for chocolate bars
A picture will help bring those share predictions to life and make it easy for people to understand. Let's make a bar plot of the shares.
Diese Übung ist Teil des Kurses
Choice Modeling for Marketing in R
Anleitung zur Übung
- I've written the first line of code that computes the shares and saves them to
shares
. - You should fill in the missing inputs to
barplot()
. The first input should be the shares, which are stored inshares$share
. - The second input should be the names of the different types of chocolate, which we can get from the chocolate data
levels(chocolate$Type)
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# compute and save the share prediction
shares <- predict_mnl(choc_m2, ghir_choc)
# make a barplot of the shares
barplot(____,
horiz = TRUE, col="tomato2",
xlab = "Predicted Market Share",
main = "Shares for Ghiradelli chocolate bars at $3 each",
names.arg = ____)