Session Ready
Exercise

How many are there? - Part two

degree_holders contains the number of BSc, MSc & PhD holders in the US. In this exercise you will visualize this data using a ggplot2 plot. If you're not yet familiar with the ggplot2 syntax, check our interactive tutorial.

ggplot2's emphasis is on rapidly and easily visualizing your data for exploration and reporting using the grammar of graphics. A visualization will often help you to get to insights faster, and will make it easier to communicate your results with your peers.

Let's make a simple barplot with the number of Bachelors/Masters/Phd's in the US on the y-axis and the different degrees on the x-axis.

Instructions
100 XP
  • Load the ggplot2 package.
  • ggplot() takes two main arguments: the dataset, degree_holders, and a function aes(): the aesthetics that will map your variables to the various parts of the plot (x-axis, y-axis, color of the bars, etc). Finish the command:
    • Inside aes() map Degree onto x, count onto y and Degree onto fill.
    • Specify stat = "identity" inside geom_bar().
    • Make sure you give the axes appropriate titles! Label the x-axis with "Degree" and the y-axis with "No of People".
    • Title the graph "Comparing Degree Holders in the US".