Introduction

Bar Charts have become one of the most popular ways of visualizing data. They are aesthetically pleasing and require little explanation.

R Packages and Dependencies

This post will focus on using the R visualization package ggplot2, which is found in the tidyverse package. The ggplot2 package is used to create bar charts.

library(readxl)
library(tidyverse)
library(grid)
library(gridExtra)
library(ggplot2)

The data sourcing and wrangling code is not included in this document, but can be found here.

What is a bar chart?

A bar chart represents data in rectangular bars with length of the bar proportional to the value of the variable. R uses the function barplot() to create bar charts. R can draw both vertical and Horizontal bars in the bar chart. In bar chart each of the bars can be given different colors.

Consider the following bar chart:

What conclusions about state GDP can you draw from this plot? You might notice that in 2014:

From this chart, we can identify that there is no relationship between geography and GDP. States with high GDPs are far away from each other, but we gain nice understanding of which countries are highest producers in the world.

While this chart looks pretty and provides a good bit of economic information, it has many analytical shortcomings. The first main weakness to this chart is that we cannot see the difference in GDP and net ranking among countries. The simplest way to visualize the difference in GDP between each state would be to create a bar chart.

The bar chart is the best visual for communicating just how much larger USA’s GDP is than any other country. When looking at our original chart, you may have noticed China and Japan were the second and third ranking states; however, it was not clear that China was almost two times more than the other countries except for USA!

On our original chart, the difference in GDP between USA and the countries which rank below was too small to notice a how big are differences.

Conclusion

The bar chart best visualizes the difference in GDP.