Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
What we will learn
Know your problem
Know your data
Visualize your data - bar chart
12. Add historical data
Work with your chart
Check yourself

Instruction

From the previous chart, which you can see in the viewer on the right, we can conclude that alcohol consumption in Zimbabwe has increased very much during the last 15 years. In saying this, we assume that 2014's unusually high level is an outlier (something that's true but not usual in the dataset). We base this assumption on the fact that until 2000, alcohol consumption levels were low. But is this assumption accurate? To correctly assess the quality of the current change, we should compare it with historical data.

To understand the current situation, add historical data to your chart.

If you have access to your time series' previous values, you can add them to your chart. This will help you understand the importance of the current data's changes.

The WHO database has data for alcohol consumption in Zimbabwe from 1980 to 20141. The full time series is available in the zimbabwe_consumption_2 dataset, which is shown below. Note: The year column is already formatted as a date.

        country    year        consumption
1      Zimbabwe 1980-01-01        5.77
2      Zimbabwe 1981-01-01        6.22
3      Zimbabwe 1982-01-01        7.00
4      Zimbabwe 1983-01-01        7.14
5      Zimbabwe 1984-01-01        7.27

1. Source: Recorded alcohol per capita consumption, 1980-1999. The data was retrieved on July 1, 2017

Exercise

Re-draw your bar chart, this time for zimbabwe_consumption_2. Save the plot to the bar object. Look at the new plot. Is your interpretation of this time series different than it was before?

Stuck? Here's a hint!

You should write:

bar <- ggplot(
    data = zimbabwe_consumption_2, 
    aes(x = year, y = consumption)) + 
  geom_col() + 
  theme(
    panel.grid.major.x = element_blank(), 
    panel.grid.minor.x = element_blank())