Exercise 5- Plotting Prediction Results
Make a barplot based on the result from the previous exercise.
This exercise is part of the course
HarvardX Data Science Module 4 - Inference and Modeling
Exercise instructions
- Reorder the states in order of the proportion of hits.
- Using
ggplot
, set the aesthetic with state as the x-variable and proportion of hits as the y-variable. - Use
geom_bar
to indicate that we want to plot a barplot. Specifcystat = "identity"
to indicate that the height of the bar should match the value. - Use
coord_flip
to flip the axes so the states are displayed from top to bottom and proportions are displayed from left to right.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# The `p_hits` data have already been loaded for you. Use the `head` function to examine it.
head(p_hits)
# Make a barplot of the proportion of hits for each state