1. Learn
  2. /
  3. Courses
  4. /
  5. Exploratory Data Analysis in R

Connected

Exercise

Side-by-side bar charts

While a contingency table represents the counts numerically, it's often more useful to represent them graphically.

Here you'll construct two side-by-side bar charts of the comics data. This shows that there can often be two or more options for presenting the same data. Passing the argument position = "dodge" to geom_bar() says that you want a side-by-side (i.e. not stacked) bar chart.

Instructions

100 XP
  • Load the ggplot2 package.
  • Create a side-by-side bar chart with align on the x-axis and gender as the fill aesthetic.
  • Create another side-by-side bar chart with gender on the x-axis and align as the fill aesthetic. Rotate the axis labels 90 degrees to help readability.