Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Visualize your data - line chart
4. Draw a line chart
Work with your chart
Check yourself


Now we know everything necessary to plot a line chart, so let's do this in R.

The only new thing we need is one piece of code – a new geometry, geom_line(), which we will add to our standard ggplot syntax:

ggplot(data=dataset, mapping=aes(x=variable_x, y=variable_y)) + geom_line()


Plot the data on the line chart. Use the above syntax to and make the dataset zimbabwe_consumption_2. Set consumption as y and year as x. Pass the whole command to the line object.

Stuck? Here's a hint!

You should write:

line <- ggplot(
  data = zimbabwe_consumption_2, 
  aes(x = year, y = consumption)) +