Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • twr1m15/fridayFagPackets
  • ba1e12/fridayFagPackets
  • SERG/fridayFagPackets
3 results
Show changes
Commits on Source (26)
# useful functions
# use source(here::here("R", "functions.R")) to load
require(flextable) # use require so it fails if not present & can't install
makeFlexTable <- function(df, cap = "caption"){
# makes a pretty flextable - see https://cran.r-project.org/web/packages/flextable/index.html
ft <- flextable::flextable(df)
ft <- flextable::colformat_double(ft, digits = 1)
ft <- flextable::fontsize(ft, size = 9)
ft <- flextable::fontsize(ft, size = 10, part = "header")
ft <- flextable::set_caption(ft, caption = cap)
return(flextable::autofit(ft))
}
\ No newline at end of file
# fridayFagPackets
A repo for our fridayFagPacket data notes (numbers that could have been done on the back of one and should probably come with a similar health warning).
A repo for our [fridayFagPacket](https://energy.soton.ac.uk/friday-fag-packets/) data notes (numbers that could have been done on the back of one and should probably come with a similar health warning).
* docs - where we (usually) keep outputs - these are published on [energy.soton](https://energy.soton.ac.uk/friday-fag-packets/)
* data - where we keep (public) data we used
......
This diff is collapsed.
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
# fridayFagPacket
# fridayFagPackets
A repo for our fridayFagPacket data notes (numbers that could have been done on the back of one and should probably come with a similar health warning)
A repo for our [fridayFagPacket](https://energy.soton.ac.uk/friday-fag-packets/) data notes (numbers that could have been done on the back of one and should probably come with a similar health warning)
* 2022-10-06 - [GDP & emissions - degrowthing or decoupling?](UK_GDP_emissions.html)
* 2020-10-16 - [retrofit or bust](retrofitOrBust.html)
* 2018-06-15 - [UK household power demand and #worldcup2018](https://energy.soton.ac.uk/uk-household-power-demand-and-worldcup2018/)
* 2018-05-30 - [Super Saturday and spikes in demand](https://energy.soton.ac.uk/super-saturday-and-spikes-in-demand/)
* 2017-01-20 - [A Most Unusual Sunday](https://energy.soton.ac.uk/a-most-unusual-sunday/)
\ No newline at end of file
* 2017-01-20 - [A Most Unusual Sunday](https://energy.soton.ac.uk/a-most-unusual-sunday/)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
---
title: "GDP & emissions - degrowthing or decoupling?"
author: "Ben Anderson & Tom Rushby"
date: "2022-10-06"
date-modified: "`r Sys.time()`"
format:
html:
self-contained: true
toc: true
code-fold: true
editor: visual
---
```{r}
#| label: setup
#| echo: false
#| warning: false
library(data.table)
library(here)
library(ggplot2)
library(skimr)
```
# What's all this about de-growth?
\<sigh\>
# Data
Downloaded from the awesome [OurWorldInData](https://ourworldindata.org/grapher/co2-emissions-and-gdp?country=~GBR).
```{r}
#| label: loasdData
dt_abs <- data.table::fread(here::here("data", "co2-emissions-and-gdp.csv"))
dt_pc <- data.table::fread(here::here("data", "co2-emissions-and-gdp-per-capita.csv"))
```
# UK: absolute GDP & emissions
First we'll try production emissions.
```{r}
#| label: fig-ukPlotProd
#| fig-cap: UK GDP vs production emissions over time.
#| warning: false
plotDT <- dt_abs[Entity == "United Kingdom"]
ggplot2::ggplot(plotDT, aes(y = as.numeric(`GDP, PPP (constant 2017 international $)`)/1000000000,
x = as.numeric(`Annual CO2 emissions`)/1000000,
alpha = Year)) +
geom_point() +
labs(x = "Annual CO2 emissions (production-based, gT)",
y = "GDP $bn (constant 2017 $)")
```
Next we'll try consumption emissions.
Note that 2020 consumption-based emissions data is missing so you don't see the downtick
```{r}
#| label: fig-ukPlotCons
#| fig-cap: UK GDP vs consumption emissions over time.
#| warning: false
plotDT <- dt_abs[Entity == "United Kingdom"]
ggplot2::ggplot(plotDT, aes(y = as.numeric(`GDP, PPP (constant 2017 international $)`)/1000000000,
x = as.numeric(`Annual consumption-based CO2 emissions`)/1000000,
alpha = Year)) +
geom_point() +
labs(x = "Annual CO2 emissions (consumption-based, gT)",
y = "GDP $bn (constant 2017 $)")
```
# UK: per capita GDP & emissions
Since we'll be dividing everything pairwise by the same denominator, nothing much should change...
First we'll try production emissions.
```{r}
#| label: fig-ukPlotProdPcc
#| fig-cap: UK GDP vs production emissions over time.
#| warning: false
plotDT <- dt_pc[Entity == "United Kingdom"]
ggplot2::ggplot(plotDT, aes(y = as.numeric(`GDP per capita, PPP (constant 2017 international $)`),
x = as.numeric(`Annual CO2 emissions (per capita)`),
alpha = Year)) +
geom_point() +
labs(x = "Annual CO2 emissions per capita (production-based, T)",
y = "GDP per capita (constant 2017 $)")
```
Next we'll try consumption emissions.
Note that 2020 consumption-based emissions data is missing so you don't see the downtick
```{r}
#| label: fig-ukPlotConsPcc
#| fig-cap: UK GDP vs consumption emissions over time.
#| warning: false
plotDT <- dt_pc[Entity == "United Kingdom"]
ggplot2::ggplot(plotDT, aes(y = as.numeric(`GDP per capita, PPP (constant 2017 international $)`),
x = as.numeric(`Annual consumption-based CO2 emissions (per capita)`),
alpha = Year)) +
geom_point() +
labs(x = "Annual CO2 emissions per capita (consumption-based, T)",
y = "GDP per capita (constant 2017 $)")
```
# Whom do we love?
[quarto](https://quarto.org/)
[data.table](https://www.rdocumentation.org/packages/data.table/versions/1.14.2)
[ggplot2](https://www.rdocumentation.org/packages/ggplot2/versions/3.3.6)
[here](https://www.rdocumentation.org/packages/here/versions/1.0.1)
[skimr](https://www.rdocumentation.org/packages/skimr/versions/2.1.4)
# Data descriptions
Check
Skim the absolute data:
```{r}
#| label: skimAbs
skimr::skim(dt_abs)
```
Skim the per capita data
```{r}
#| label: skimPC
skimr::skim(dt_pc)
```
```{r}
#| label: runToHere
# hidden chunk
```
......@@ -42,140 +42,174 @@ Numbers that could have been done on the back of one and should probably come wi
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(data.table)
library(ggplot2)
```
# It's the cats, stupid
Inspired by `@giulio_mattioli`'s [recent paper on the car dependence of dog ownership](https://twitter.com/giulio_mattioli/status/1466361022747455492) we thought we'd take a look at [cats](https://twitter.com/giulio_mattioli/status/1466710752606179331) and residential energy demand. Why? Well people like to keep their cats warm but, more importantly, they also cut big holes in doors and/or windows to let the cats in and out. Hardly a thermally sealed envelope!
Inspired by `@giulio_mattioli`'s [recent paper on the car dependence of dog ownership](https://twitter.com/giulio_mattioli/status/1466361022747455492) we thought we'd take a look at [cats](https://twitter.com/giulio_mattioli/status/1466710752606179331) and residential energy demand. Why? Well people like to keep their cats warm but, more importantly, they also cut big holes in doors and/or windows to let the cats in and out. Hardly a thermally sealed envelope...
# What's the data?
For now we're using:
* postcode sector level estimates of cat ownership in the UK in 2015. Does such a thing exist? [YEAH](https://data.gov.uk/dataset/febd29ff-7e7d-4f82-9908-031f7f0e0860/cat-population-per-postcode-district)! "_This dataset gives the mean estimate for population for each district, and was generated as part of the delivery of commissioned research. The data contained within this dataset are modelled figures, based on national estimates for pet population, and available information on Veterinary activity across GB. The data are accurate as of 01/01/2015. The data provided are summarised to the postcode district level. Further information on this research is available in a research publication by James Aegerter, David Fouracre & Graham C. Smith, discussing the structure and density of pet cat and dog populations across Great Britain._"
* LSOA level data on [gas](https://www.gov.uk/government/collections/sub-national-gas-consumption-data) and [electricity](https://www.gov.uk/government/collections/sub-national-electricity-consumption-data) 'consumption' at LSOA/SOA level for 2015 aggregated to postcode sectors
* [Indices of Deprivation 2019](https://www.gov.uk/government/statistics/english-indices-of-deprivation-2019) for England
```{r loadData}
gas_dt <- data.table::fread(paste0(dp, "/beis/subnationalGas/lsoaDom/LSOA_GAS_2015.csv.gz"))
gas_dt[, lsoa11cd := `Lower Layer Super Output Area (LSOA) Code`]
gas_dt[, mean_gas_kWh := `Mean consumption (kWh per meter)`]
gas_dt[, total_gas_kWh := `Consumption (kWh)`]
gas_dt[, nGasMeters := `Number of consuming meters`]
elec_dt <- data.table::fread(paste0(dp, "/beis/subnationalElec/lsoaDom/LSOA_ELEC_2015.csv.gz"))
elec_dt[, lsoa11cd := `Lower Layer Super Output Area (LSOA) Code`]
elec_dt[, mean_elec_kWh := `Mean domestic electricity consumption
(kWh per meter)`]
elec_dt[, total_elec_kWh := `Total domestic electricity consumption (kWh)`]
elec_dt[, nElecMeters := `Total number of domestic electricity meters`]
setkey(gas_dt, lsoa11cd)
setkey(elec_dt, lsoa11cd)
setkey(lsoa_DT, lsoa11cd)
merged_lsoa_DT <- gas_dt[, .(lsoa11cd, mean_gas_kWh, total_gas_kWh, nGasMeters)][elec_dt[, .(lsoa11cd,mean_elec_kWh,total_elec_kWh,nElecMeters)]][lsoa_DT]
# remove the record for postcodes which did not have a postcode sector
message("How many LSOAs do not map to a postcode sector?")
nrow(merged_lsoa_DT[is.na(pcd_sector)])
head(merged_lsoa_DT[is.na(pcd_sector)])
# !is.na(pcd_sector)
postcode_sector_energy <- merged_lsoa_DT[, .(nLSOAs = .N,
nPostcodes = sum(nPostcodes),
mean_gas_kWh = mean(mean_gas_kWh, na.rm = TRUE),
total_gas_kWh = sum(total_gas_kWh, na.rm = TRUE),
mean_elec_kWh = mean(mean_elec_kWh, na.rm = TRUE),
total_elec_kWh = sum(total_elec_kWh, na.rm = TRUE),
nGasMeters = sum(nGasMeters, na.rm = TRUE),
nElecMeters = sum(nElecMeters, na.rm = TRUE)), keyby = .(pcd_sector, ladnm, ladnmw)]
#head(postcode_sector_energy)
We could also use `@SERL_UK`'s [smart meter gas/elec data](https://twitter.com/dataknut/status/1466712963222540289?s=20), dwelling characteristics and pet ownership (but no species detail :-)
So for now we're using:
* postcode district level estimates of cat ownership in the UK in 2015. Does such a thing exist? [YEAH](https://data.gov.uk/dataset/febd29ff-7e7d-4f82-9908-031f7f0e0860/cat-population-per-postcode-district)! "_This dataset gives the mean estimate for population for each district, and was generated as part of the delivery of commissioned research. The data contained within this dataset are modelled figures, based on national estimates for pet population, and available information on Veterinary activity across GB. The data are accurate as of 01/01/2015. The data provided are summarised to the postcode district level. Further information on this research is available in a research publication by James Aegerter, David Fouracre & Graham C. Smith, discussing the structure and density of pet cat and dog populations across Great Britain._"
* experimental postcode level data on domestic [gas](https://www.gov.uk/government/collections/sub-national-gas-consumption-data) and [electricity](https://www.gov.uk/government/collections/sub-national-electricity-consumption-data) 'consumption' for 2015 aggregated to postcode districts
```{r loadCats}
# cats
cats_DT <- data.table::fread(paste0(dp, "UK_Animal and Plant Health Agency/APHA0372-Cat_Density_Postcode_District.csv"))
cats_DT[, pcd_sector := PostcodeDistrict]
cats_DT[, pcd_district := PostcodeDistrict]
setkey(cats_DT, pcd_sector)
setkey(postcode_sector_energy, pcd_sector)
setkey(cats_DT, pcd_district)
pc_district <- cats_DT[postcode_sector_energy]
nrow(cats_DT)
```
setkey(pc_district_energy_dt, pcd_district)
We could also use `@SERL_UK`'s [smart meter gas/elec data](https://twitter.com/dataknut/status/1466712963222540289?s=20), dwelling characteristics and pet ownership (but no species detail :-)
nrow(pc_district_energy_dt)
pc_district <- pc_district_energy_dt[cats_DT] # keeps only postcode districts where we have cat data
# this may include areas where we have no energy data
pc_district[, mean_Cats := EstimatedCatPopulation/nElecMeters]
nrow(pc_district)
nrow(pc_district[!is.na(GOR10NM)])
# there are postcode districts with no electricity meters - for now we'll remove them
# pending further investigation
t <- pc_district[!is.na(GOR10NM), .(nPostcodeDistricts = .N,
sumCats = sum(EstimatedCatPopulation),
sumElecMeters = sum(nElecMeters, na.rm = TRUE)), keyby=.(GOR10NM)]
t[, catsPerDistrict := sumCats/nPostcodeDistricts]
t[, catsPerDwelling := sumCats/sumElecMeters]
makeFlexTable(t, cap = "Regions covered (1 electricity meter assumed to be 1 dwelling)")
message("Total number of electricity meters:", sum(t$sumElecMeters))
```
# What do we find?
Well, in some places there seem to be a lot of estimated cats...
Well, in some places there seem to be a lot of estimated cats per household...
(We calculated mean cats per household by dividing by the number of electricity meters - probably a reasonable proxy)
(We calculated mean cats per household by dividing by the number of electricity meters - should be a reasonable proxy)
```{r maxCats}
pc_district[, mean_Cats := EstimatedCatPopulation/nElecMeters]
head(pc_district[, .(PostcodeDistrict, EstimatedCatPopulation, mean_Cats, nPostcodes, nElecMeters)][order(-mean_Cats)])
t <- head(pc_district[, .(Region = GOR10NM, PostcodeDistrict, EstimatedCatPopulation, mean_Cats, nPostcodes, nElecMeters,nGasMeters)][order(-mean_Cats)],10)
makeFlexTable(t, cap = "Top 10 postcode districts by number of cats per 'household'")
```
SA63 is in south west [Wales](https://www.google.co.uk/maps/place/Clarbeston+Road+SA63/@51.8852685,-4.9147384,12z/data=!3m1!4b1!4m5!3m4!1s0x4868d5805b12efe5:0xca42ee4bc84a2f77!8m2!3d51.8900045!4d-4.8502065) while LL23 is on the edge of the [Snowdonia National Park](https://www.google.co.uk/maps/place/Bala+LL23/@52.8953768,-3.7752989,11z/data=!3m1!4b1!4m5!3m4!1s0x4865404ae1208f67:0x65a437b997c0dfb2!8m2!3d52.8825403!4d-3.6497989)....
Do these places have some largish catteries but few houses?
```{r histoCats, fig.cap = "Histogram of mean number of cats per dwelling"}
ggplot2::ggplot(pc_district, aes(x = mean_Cats)) +
geom_histogram() +
labs(caption = "Postcode districts")
summary(pc_district$mean_Cats)
```
LL23 is on the south east corner of the [Snowdonia National Park...](https://www.google.co.uk/maps/place/Bala+LL23/@52.8953768,-3.775299,11z/data=!3m1!4b1!4m5!3m4!1s0x4865404ae1208f67:0x65a437b997c0dfb2!8m2!3d52.8825403!4d-3.6497989) while EH25 is on the outskirts of [Edinburgh](https://www.google.co.uk/maps/place/EH25/@55.8518992,-3.2076308,13z/data=!4m5!3m4!1s0x4887bf6548dd78d7:0xd6f980c5a3b93592!8m2!3d55.8560564!4d-3.1733124).
## More dwellings, more cats?
Is there a correlation between estimated total cats and the number of dwellings (electricity meters)?
Is there a correlation between estimated total cats and the number of dwellings (as measured by the number of electricity meters)?
```{r testTotalElecMeters}
ggplot2::ggplot(pc_district, aes(x = nElecMeters , y = EstimatedCatPopulation)) +
ggplot2::ggplot(pc_district[!is.na(GOR10NM)], aes(x = nElecMeters , y = EstimatedCatPopulation,
colour = GOR10NM)) +
scale_color_discrete(name = "UK `Region`") +
geom_point() +
geom_smooth()
```
## More cats, more energy?
Clearly postcode districts with more dwellings will have higher energy use totals. So we need to compare the mean number of cats per dwelling with mean energy use per dwelling.
This will need to accommodate some outliers in terms of mean number of cats as we saw above and potentially also in terms of mean energy.
```{r meanEnergyOutliers}
pc_district[, total_gas_kWh := ifelse(is.na(total_gas_kWh), 0, total_gas_kWh)]
pc_district[, total_energy_kWh := total_gas_kWh + total_elec_kWh]
pc_district[, mean_energy_kWh := total_energy_kWh/nElecMeters]
summary(pc_district$mean_energy_kWh)
t <- head(pc_district[, .(Region = GOR10NM, PostcodeDistrict, mean_energy_kWh, nPostcodes, nElecMeters,nGasMeters)][order(-mean_energy_kWh)],10)
makeFlexTable(t, cap = "Top 10 postcode districts by mean energy per 'household'")
```
Is there a correlation between estimated cat ownership and total gas use?
```{r testTotalGas}
ggplot2::ggplot(pc_district, aes(x = EstimatedCatPopulation, y = total_gas_kWh)) +
```{r meanCatsAndMeanEnergy}
ggplot2::ggplot(pc_district[!is.na(GOR10NM)],
aes(x = mean_Cats, y = mean_energy_kWh, colour = GOR10NM)) +
geom_smooth() +
geom_point()
```
Or mean gas use and mean cats?
```{r testMeanGas}
ggplot2::ggplot(pc_district, aes(x = mean_Cats, y = mean_gas_kWh)) +
ggplot2::ggplot(pc_district[!is.na(GOR10NM)],
aes(x = mean_Cats, y = mean_gas_kWh, colour = GOR10NM)) +
geom_smooth() +
geom_point()
```
## More cats, more electricity?
Or total electricity use and cats?
```{r testTotalElec}
ggplot2::ggplot(pc_district, aes(x = EstimatedCatPopulation, y = total_elec_kWh)) +
ggplot2::ggplot(pc_district[!is.na(GOR10NM)], aes(x = EstimatedCatPopulation, y = total_elec_kWh, colour = GOR10NM)) +
geom_smooth() +
geom_point()
```
Or mean elec use and mean cats?
```{r testMeanElec}
ggplot2::ggplot(pc_district, aes(x = mean_Cats, y = mean_elec_kWh)) +
ggplot2::ggplot(pc_district[!is.na(GOR10NM)], aes(x = mean_Cats, y = mean_elec_kWh, colour = GOR10NM)) +
geom_smooth() +
geom_point()
```
## More cats, more energy?
Or total energy use and total cats?
```{r testTotalEnergy}
pc_district[, total_gas_kWh := ifelse(is.na(total_gas_kWh), 0, total_gas_kWh)]
pc_district[, total_energy_kWh := total_gas_kWh + total_elec_kWh]
pc_district[, mean_energy_kWh := total_energy_kWh/nElecMeters]
ggplot2::ggplot(pc_district, aes(x = EstimatedCatPopulation, y = total_energy_kWh)) +
ggplot2::ggplot(pc_district[!is.na(GOR10NM)], aes(x = EstimatedCatPopulation, y = total_energy_kWh, colour = GOR10NM)) +
geom_smooth() +
geom_point()
```
Well, there may be something in there? Let's try a boxplot by cat deciles... Figure \@ref(fig:catDeciles)
Let's try a boxplot by cat deciles... Figure \@ref(fig:catDeciles) suggests the median energy use is higher in postcode districts with higher cat ownership.
```{r catDeciles, fig.cap = "Cat ownership deciles and total annual residenital electricity & gas use"}
pc_district[, cat_decile := dplyr::ntile(EstimatedCatPopulation, 10)]
#head(pc_district[is.na(cat_decile)])
ggplot2::ggplot(pc_district[!is.na(cat_decile)], aes(x = as.factor(cat_decile), y = total_energy_kWh/1000000)) +
ggplot2::ggplot(pc_district[!is.na(cat_decile) & !is.na(GOR10NM)], aes(x = as.factor(cat_decile), y = total_energy_kWh/1000000)) +
geom_boxplot() +
facet_wrap(. ~ GOR10NM) +
labs(x = "Cat ownership deciles",
y = "Total domestic electricity & gas GWh")
y = "Total domestic electricity & gas GWh",
caption = "Postcode districts (Data: BEIS & Animal and Plant Health Agency, 2015)")
```
Well...
......@@ -183,10 +217,19 @@ Well...
pc_district[, total_energy_kWh := total_gas_kWh + total_elec_kWh]
pc_district[, mean_energy_kWh := total_energy_kWh/nElecMeters]
ggplot2::ggplot(pc_district, aes(x = mean_Cats, y = mean_energy_kWh)) +
ggplot2::ggplot(pc_district[!is.na(GOR10NM)], aes(x = mean_Cats, y = mean_energy_kWh)) +
geom_point()
```
# Data Annexes
Cats data
```{r skimCats}
skimr::skim(cats_DT)
```
# R packages used
* bookdown [@bookdown]
......
# loads the data and runs the Rmd render
# Packages ----
library(data.table)
library(here)
# Functions ----
source(here::here("R", "functions.R"))
makeReport <- function(f){
# default = html
rmarkdown::render(input = paste0(here::here("itsTheCatsStupid", f), ".Rmd"),
......@@ -8,17 +17,52 @@ makeReport <- function(f){
)
}
# >> run report ----
# Set data path ----
dp <- "~/Dropbox/data/"
# Run report ----
#> define yaml ----
rmdFile <- "itsTheCatsStupid" # not the full path
title = "#backOfaFagPacket: Its the Cats, stupid"
subtitle = "Does cat ownership correlate with home energy demand?"
authors = "Ben Anderson"
# load the postcode data here (slow)
dp <- "~/Dropbox/data/"
postcodes_dt <- data.table::fread(paste0(dp, "UK_postcodes/PCD_OA_LSOA_MSOA_LAD_AUG20_UK_LU.csv.gz"))
postcodes_dt[, pcd_sector := tstrsplit(pcds, " ", keep = c(1))]
lsoa_DT <- postcodes_dt[, .(nPostcodes = .N), keyby = .(lsoa11cd, pcd_sector, ladnm, ladnmw)]
#> load the postcode data here (slow)
postcodes_elec_dt <- data.table::fread(paste0(dp, "beis/subnationalElec/Postcode_level_all_meters_electricity_2015.csv"))
postcodes_elec_dt[, pcd_district := data.table::tstrsplit(POSTCODE, " ", keep = c(1))]
pc_district_elec_dt <- postcodes_elec_dt[, .(elec_nPostcodes = .N,
total_elec_kWh = sum(`Consumption (kWh)`, na.rm = TRUE),
nElecMeters = sum(`Number of meters`, na.rm = TRUE)
), keyby = .(pcd_district)]
nrow(pc_district_elec_dt)
summary(pc_district_elec_dt)
postcodes_gas_dt <- data.table::fread(paste0(dp, "beis/subnationalGas/Experimental_Gas_Postcode_Statistics_2015.csv"))
postcodes_gas_dt[, pcd_district := data.table::tstrsplit(POSTCODE, " ", keep = c(1))]
pc_district_gas_dt <- postcodes_gas_dt[, .(gas_nPostcodes = .N,
total_gas_kWh = sum(`Consumption (kWh)`, na.rm = TRUE),
nGasMeters = sum(`Number of meters`, na.rm = TRUE)), keyby = .(pcd_district)]
nrow(pc_district_gas_dt)
summary(pc_district_gas_dt)
setkey(pc_district_elec_dt, pcd_district)
setkey(pc_district_gas_dt, pcd_district)
pc_district_energy_dt <- pc_district_gas_dt[pc_district_elec_dt]
pc_district_energy_dt[, mean_gas_kWh := total_gas_kWh/nGasMeters]
pc_district_energy_dt[, mean_elec_kWh := total_elec_kWh/nElecMeters]
# load one we prepared earlier using https://git.soton.ac.uk/SERG/mapping-with-r/-/blob/master/R/postcodeWrangling.R
pc_district_region_dt <- data.table::fread(paste0(dp, "UK_postcodes/postcode_districts_2016.csv"))
setkey(pc_district_region_dt, pcd_district)
nrow(pc_district_region_dt)
pc_district_region_dt[, .(n = .N), keyby = .(GOR10CD, GOR10NM)]
nrow(pc_district_energy_dt)
pc_district_energy_dt <- pc_district_energy_dt[pc_district_region_dt]
nrow(pc_district_energy_dt)
# re-run report here
makeReport(rmdFile)
\ No newline at end of file
#> re-run report here ----
makeReport(rmdFile)