CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Choice Modeling for Marketing in R

Afficher le cours

Instructions

  • 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 in shares$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)

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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 = ____)
Modifier et exécuter le code