Session Ready
Exercise

Price differences in high quality marijuana per state

For this final exercise, we're going to investigate data from this repository of historical marijuana prices. A data frame weed is availabe in your workspace. It has more than 20.000 obserations and 2 variables: state and price.

As a first step, you'll again have to use some dplyr magic to get average weed prices per state. Next, you can use the choroplethrMaps package to map the weed prices per state. More specifically, you'll use state_choropleth(): it takes a data frame with two columns: region and value. Being able to link information to particular geographic locations can be very insightful and will help you to reveal hidden knowledge.

All packages you need are loaded, so you can start coding straight away!

Instructions
100 XP
  • Fill in the group_by() and summarise() commands to create a data frame avg_weed with average weed prices per state. avg_weed should contain two columns: state and avg_price.
  • Change the column names of avg_weed to c("region", "value") so they can be used by the state_choropleth() function.
  • Now that avg_weed has the correct column names, go ahead and call state_choropleth() on it. Still inside state_choropleth(), specify the title to be "Average Weed Price Per State" and legend to be "Price in $".