diff --git a/DECC.Rproj b/DECC.Rproj new file mode 100644 index 0000000000000000000000000000000000000000..8e3c2ebc99e2e337f7d69948b93529a437590b27 --- /dev/null +++ b/DECC.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/LSOA-Domestic/process_DECC_LSOA_2011.R b/LSOA-Domestic/process_DECC_LSOA_2011.R new file mode 100644 index 0000000000000000000000000000000000000000..cdf2ba6f070354cc8e7df921449abd25990bd28a --- /dev/null +++ b/LSOA-Domestic/process_DECC_LSOA_2011.R @@ -0,0 +1,78 @@ +######################################### +#* Script to: +# * - Extract data from DECC LSOA level domestic energy consumption data +# (https://www.gov.uk/government/collections/mlsoa-and-llsoa-electricity-and-gas-estimates) +# +# Copyright (C) 2014-2015 University of Southampton +# +# Author: Ben Anderson (b.anderson@soton.ac.uk, @dataknut, https://github.com/dataknut) +# [Energy & Climate Change, Faculty of Engineering & Environment, University of Southampton] +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License +# (http://choosealicense.com/licenses/gpl-2.0/), or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# YMMV - http://en.wiktionary.org/wiki/YMMV + +###################################### + +# Housekeeping ---- + +# clear the workspace +rm(list=ls()) + +# libraries +library(data.table) +library(xlsx) + +# just to check where R thinks we are +getwd() + +# data path +dpath <- "~/Documents/Work/Data/DECC/LSOA Energy Data/2011/" +# census path +cpath <- "~/Documents/Work/Data/UK Census/2011Data/EW/lsoa/processed/" + +efile <- paste0(dpath,"Lower_Layer_Super_Output_Area__LSOA__domestic_electricity_estimates_2011_All_data.csv") +# electricity file +gfile <- paste0(dpath,"Lower_layer_Super_Output_Area__LSOA__domestic_gas_estimates_2011_Look-up_spreadsheets.xlsx") + +# Load data ---- +# first row contains variable names +lsoaElec2011_DT <- fread(efile, header = TRUE, + col.names = c("lan", + "lac", + "mlsoa", + "lsoa", + "kWh_ord", + "kWh_e7", + "kWh_tot", + "nmeters_ord", + "nmeters_e7", + "nmeters_tot", + "meankWh_ord", + "meankWh_e7", + "meankWh_tot" + ) + ) + +# Gas data is not as easy to process as each GOR is in a different tab +# and also there are some rows which are for multiple LSOAs due to potential +# disclosure issues +#lsoaGas2011_DT <- as.data.table( +# read.xlsx(gfile, sheetName = ""XXXXX", 1) +#) + +head(lsoaElec2011_DT) + +# set join key +lsoaElec2011_DT$zonecode <- lsoaElec2011_DT$lsoa +setkey(lsoaElec2011_DT, zonecode) + +# Load Census data ---- \ No newline at end of file