Chapter 6 Practice

6.1 Exercise

60:00

Use the transport_expenditure data to create a time series showing household expenditure on transport over time. The data shows household spending per week in pounds on different types of transport and subcategories of transport, such as petrol, between 2002 and 2021.

In your analysis, try to use as many components of creating a complex chart in ggplot2 covered in this course.

  1. Inspect the transport_expenditure data and decide on an area you would like to analyse/compare.
  2. Tidy and manipulate the data in preparation to create a time series chart.
  3. Create a multi-line time series chart data in ggplot2.
  4. Adapt or change the scale of your chart to one you find appropriate for your analysis.
  5. Add a title, and label your x and y axis.
  6. Create a theme by changing text elements, line elements, legend and background elements.
  7. Add an annotation to enhance the readability or narrative of your chart.

This is a preview of the data you’ll be using:

transport_group_category spend_category spend_subcategory year spend_per_week_GBP
Motoring and bicycle costs Purchase of vehicles New cars and vans 2002 10.7
Motoring and bicycle costs Purchase of vehicles New cars and vans 2003 11.3
Motoring and bicycle costs Purchase of vehicles New cars and vans 2004 11.4
Motoring and bicycle costs Purchase of vehicles New cars and vans 2005 10.1
Motoring and bicycle costs Purchase of vehicles New cars and vans 2006 8.0
Motoring and bicycle costs Purchase of vehicles New cars and vans 2007 7.8