library(tidyverse)
ghg <- read_csv("https://raw.githubusercontent.com/uqlibrary/technology-training/master/R/reports/aus_ghg_2022.csv")Greenhouse Gas Emissions in Australia
National Greenhouse Gas data
Our data comes from the National Inventory by Economic Sector. The values are reported in Mt CO2-e.
Import the data
Let’s import the CSV:
Let’s see the table:
| year | Agriculture, Forestry and Fishing | Forestry - Changes in Inventories | Mining | Manufacturing | Electricity, Gas, Water and Waste Services | Services, Construction and Transport | Residential |
|---|---|---|---|---|---|---|---|
| 1990 | 280.27 | -19.58 | 46.25 | 68.68 | 154.68 | 35.93 | 49.15 |
| 1991 | 261.19 | -19.90 | 46.87 | 68.53 | 156.23 | 33.43 | 48.64 |
| 1992 | 215.30 | -26.24 | 49.05 | 68.76 | 159.32 | 39.05 | 49.28 |
| 1993 | 197.36 | -30.23 | 49.80 | 69.11 | 158.42 | 38.72 | 50.33 |
| 1994 | 177.51 | -16.91 | 48.05 | 69.25 | 158.41 | 36.37 | 50.69 |
| 1995 | 160.99 | -21.08 | 50.34 | 69.08 | 164.54 | 35.04 | 52.07 |
| 1996 | 158.99 | -23.02 | 51.84 | 67.26 | 167.00 | 37.43 | 52.66 |
| 1997 | 158.87 | -30.32 | 55.66 | 67.95 | 172.27 | 33.21 | 52.67 |
| 1998 | 156.06 | -21.42 | 57.62 | 68.50 | 183.98 | 30.39 | 52.81 |
| 1999 | 174.01 | -25.25 | 55.63 | 69.86 | 189.91 | 32.41 | 51.77 |
| 2000 | 172.79 | -20.36 | 59.28 | 68.95 | 193.32 | 42.73 | 53.10 |
| 2001 | 187.22 | -23.36 | 59.54 | 68.98 | 200.87 | 39.81 | 53.43 |
| 2002 | 198.92 | -34.96 | 59.81 | 68.98 | 202.55 | 40.66 | 55.02 |
| 2003 | 195.84 | -38.75 | 57.39 | 71.94 | 203.03 | 44.03 | 57.03 |
| 2004 | 173.40 | -44.85 | 58.41 | 73.36 | 210.91 | 44.93 | 58.55 |
| 2005 | 205.96 | -44.28 | 61.65 | 72.50 | 212.00 | 43.00 | 58.62 |
| 2006 | 228.18 | -43.29 | 62.71 | 71.60 | 216.32 | 49.98 | 59.43 |
| 2007 | 196.86 | -45.84 | 65.79 | 73.97 | 219.38 | 56.22 | 59.75 |
| 2008 | 173.34 | -42.81 | 65.62 | 75.02 | 221.62 | 61.58 | 60.27 |
| 2009 | 152.90 | -27.95 | 71.31 | 68.48 | 223.30 | 59.48 | 60.35 |
| 2010 | 151.08 | -19.33 | 71.00 | 70.46 | 217.99 | 57.22 | 60.75 |
| 2011 | 123.47 | -23.93 | 71.66 | 70.94 | 210.97 | 62.65 | 61.85 |
| 2012 | 114.60 | -29.78 | 74.32 | 68.66 | 209.11 | 55.76 | 61.98 |
| 2013 | 133.00 | -35.92 | 77.26 | 67.41 | 195.43 | 57.14 | 62.78 |
| 2014 | 133.84 | -47.35 | 76.41 | 66.08 | 188.92 | 57.54 | 62.89 |
| 2015 | 118.31 | -50.14 | 82.94 | 62.10 | 195.84 | 60.28 | 64.37 |
| 2016 | 80.28 | -58.61 | 88.22 | 59.65 | 201.23 | 56.91 | 63.37 |
| 2017 | 112.77 | -55.67 | 94.36 | 59.06 | 196.36 | 57.91 | 64.12 |
| 2018 | 95.74 | -61.24 | 100.43 | 59.47 | 189.69 | 52.67 | 64.92 |
| 2019 | 68.10 | -48.74 | 106.38 | 58.36 | 184.98 | 57.19 | 64.45 |
| 2020 | 63.74 | -40.29 | 107.25 | 58.45 | 174.98 | 50.35 | 60.06 |
| 2021 | 39.54 | -37.78 | 101.55 | 59.70 | 167.35 | 51.02 | 57.36 |
| 2022 | 27.07 | -28.29 | 101.28 | 58.83 | 161.43 | 57.70 | 54.60 |
Some stats
The dataset contains GHG emissions for the period 1990 to 2022. The maximum GHG emissions for the mining sector is 107.25 Mt CO2-e. We used the functions max() and min().
Tidy the data
Let’s reshape our table from wide format to long format:
ghg_tidy <- pivot_longer(ghg,
-year,
names_to = "sector",
values_to = "emissions")Visualise
How did emissions evolve over the years?
ggplot(ghg_tidy,
aes(x = year,
y = emissions,
colour = sector)) +
geom_line()Make it interactive:
p <- ggplot(ghg_tidy,
aes(x = year,
y = emissions,
colour = sector)) +
geom_line()
library(plotly)
ggplotly(p)