ComeçarComece de graça

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.

Este exercício faz parte do curso

Choice Modeling for Marketing in R

Ver curso

Instruções do exercício

  • 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)

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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 = ____)
Editar e executar o código