Commit e0be4894 authored by Ben Anderson's avatar Ben Anderson
Browse files

added project

parent f94c500b
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
#########################################
#* 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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment