-
Notifications
You must be signed in to change notification settings - Fork 1
Stock Subsets
subset -> conditioned, according to assumptions, requirements, needs
According to the purpose of the study, a selection of elements can be performed. This makes possible to perform an analysis in three different ways:
- stock evaluation : considering all the elements of the dataset
- group study : selecting a subset of the dataset; for example for policy testing
- single element : for studying an specific or general case
For this however, a degree of knowledge regarding the dwelling archetypes found in the sources of information is required.
The command tbl_df may be convenient to have a quick glimpse of the existing datasets.
tbl_df(tbl.EHS.combinedSets.der) tbl_df(tbl.CHMwEHS.expanded.der)
It must be noted that the full mode must be defined.
mode -> full
The variable var.funListAim contains the possible options to perform the subset by variables or conditions.
lst.EnHub.TypologyConfigurations
names(lst.EnHub.TypologyConfigurations)
The function fnCombineEHSs() combines the loaded EHS datasets. This is convenient to look at the whole survey data in one go, but is not very efficient to be used iteratively.
tbl.EHS.combinedSetSubset.der <- subset(fnCombineEHSs()) dim(tbl.EHS.combinedSetSubset.der)
This example follows the same combination of EHS datasets; however it then restricts the survey data to a single or group of selected archetypes.
tbl.EHS.combinedSetSubset.der <- subset(fnCombineEHSs()) id.model <- 1 tbl.EHS.combinedSetSubset.der <- tbl.EHS.combinedSetSubset.der[id.model,] dim(tbl.EHS.combinedSetSubset.der)
In this example, the combined EHS is formed with an additional restriction.
tmp <- subset(fnCombineEHSs(), .agl_floor_area > 10000)
Then, the resulting dataset is further reduced by addition 3 constraints: (削除) type, region and tenure (削除ここまで).
tbl.EHS.combinedSetSubset.der <- fnReducesEHSSubset(tmp, opt.DwellingType=as.character(lst.EnHub.TypologyConfigurations[["type"]][1:3,]), opt.Region=as.character(lst.EnHub.TypologyConfigurations[["region"]][3,]), opt.Tenure=as.character(lst.EnHub.TypologyConfigurations[["tenure"]][2,]))
With the smaller data set, it is now possible to investigate a number of selected variables only.
dim(tbl.EHS.combinedSetSubset.der) tbl.EHS.combinedSetSubset.der[,c('aacode','aagpd1011','aagph1011', 'dwtype8x','.type','.region','tenure4x', '.agl_floor_area','mainfuel','watersys', '.occupant_adult','.occupant_child')]
dB.EHS.subset <- fnEHS.Subset(subset(dB.EHS.merge.fn(), aagpd1011 > 0 & aagph1011 > 0 & .occupant_adult==4 & .isattic==T & .iscellar==T)) dim(dB.EHS.subset) dB.EHS.subset; dB.EHS.subset$X # resulting subset and reference ids
dB.EHS.subset <- fnEHS.Subset(dB.EHS=dB.EHS.merge.fn(), opt.DwellingType=as.character(var.funListAim[["type"]][6,]), opt.Region=as.character(var.funListAim[["region"]][1,]), opt.BuiltAge=as.character(var.funListAim[["ageband"]][9,]), opt.Tenure=as.character(var.funListAim[["tenure"]][3,])) dim(dB.EHS.subset) dB.EHS.subset; dB.EHS.subset$X
a wider subset
dB.EHS.subset <- fnEHS.Subset(dB.EHS=dB.EHS.merge.fn(), opt.DwellingType=as.character(var.funListAim[["type"]][4,]), opt.Tenure=as.character(var.funListAim[["tenure"]][3,])) dim(dB.EHS.subset) data.table::data.table(dB.EHS.subset)
first, a subset based on numeric condition: aagpd1011:weights
tmp <- subset(dB.EHS.merge.fn(), aagpd1011 > 2900)
And then, a subset based on the typology
dB.EHS.subset <- fnEHS.Subset(tmp, opt.DwellingType=as.character(var.funListAim[["type"]][4,]), opt.Tenure=as.character(var.funListAim[["tenure"]][3,])) data.table::data.table(dB.EHS.subset)
This examples explains the conformation of a subset including the most representative cases of:
- detached houses
- with attic
- with basement
- with central Heating
- tenure: owner occupied
tmp <- subset(fnCombineEHSs(), .isattic == T & .iscellar == T) tbl.EHS.combinedSetSubset.der <- fnReducesEHSSubset(tmp, opt.DwellingType=as.character(lst.EnHub.TypologyConfigurations[["type"]][4,]), opt.SpaceHeat=as.character(lst.EnHub.TypologyConfigurations[["spaceheat"]][1,]), opt.Tenure=as.character(lst.EnHub.TypologyConfigurations[["tenure"]][2,])) dim(tbl.EHS.combinedSetSubset.der) data.table::data.table(tbl.EHS.combinedSetSubset.der)
This examples explains the conformation of a subset including the most representative cases of:
- detached houses
- East Midlands
- countryside
- owner occupied
tmp <- subset(fnCombineEHSs()) tbl.EHS.combinedSetSubset.der <- fnReducesEHSSubset(tmp, opt.DwellingType=as.character(lst.EnHub.TypologyConfigurations[["type"]][4,]), opt.Terrain=as.character(lst.EnHub.TypologyConfigurations[["terrain"]][2,]), opt.Region=as.character(lst.EnHub.TypologyConfigurations[["region"]][2,]), opt.Tenure=as.character(lst.EnHub.TypologyConfigurations[["tenure"]][2,])) dim(tbl.EHS.combinedSetSubset.der) data.table::data.table(tbl.EHS.combinedSetSubset.der)
This examples creates a subset based on gas and electricity metrics
tmp <- subset(tbl.CHM.outputs.raw, EnergyConsumptionGas>0 & EnergyConsumptionOil==0 & EnergyConsumptionSolid==0 & EnergyConsumptionBiomass==0 & EnergyConsumptionElectricity>0 & EnergyConsumptionRenewable==0 & EnergyConsumptionSpaceHeatingmain>0 & EnergyConsumptionSpaceHeatingsecondary>=0 & EnergyConsumptionWaterHeating>0 & EnergyConsumptionSpaceCooling==0 & EnergyConsumptionLighting>0 & EnergyConsumptionElectricalAppliances>0 & EnergyConsumptionCooking>0 & EnergyConsumptionPumpsandfans>=0); tmp.id <- rownames(tmp) tbl.EHS.combinedSetSubset.der <- fnCombineEHSs() tbl.EHS.combinedSetSubset.der <- tbl.EHS.combinedSetSubset.der[tmp.id,] paste("This subset represents ", format(round(dim(tmp)[1] / dim(tbl.CHM.outputs.raw)[1] * 100,1),big.mark=",",scientific=F), "% of UK dwelling stock / ") sample(tbl.EHS.combinedSetSubset.der$aacode,5)
This examples reviews statistic indictors of the stock, and then selects a given example.
CHM_Output_Percentage <- read.csv("myData/CHM/CHM_Output_Percentage.csv", row.names=1) (avgDwell <- as.data.frame(CHM_Output_Percentage * 16700)) # 16700 is the average energy demand per household var.sankeyDwellingFrame <- drawDwellingInSankey(14,115,-3,105) drawSankeyDomestic(avgDwell, var.sankeyDwellingFrame, 0.6, 1000, paste("Sankey Average",sep=""), "darkgray", "darkgray") colSums(avgDwell) rowSums(avgDwell) tmp <- subset(tbl.CHM.outputs.raw, EnergyConsumptionGas>11000 & EnergyConsumptionGas<11500 & EnergyConsumptionOil>=0 & EnergyConsumptionSolid>=0 & EnergyConsumptionBiomass>=0 & EnergyConsumptionElectricity>4000 & EnergyConsumptionElectricity<4150 & EnergyConsumptionRenewable>=0 & EnergyConsumptionSpaceHeatingmain>0 & EnergyConsumptionSpaceHeatingsecondary>=0 & EnergyConsumptionWaterHeating>=0 & EnergyConsumptionSpaceCooling>=0 & EnergyConsumptionLighting>500 & EnergyConsumptionLighting<550 & EnergyConsumptionElectricalAppliances>=0 & EnergyConsumptionCooking>=0 & EnergyConsumptionPumpsandfans>=0); dim(tmp)[1] tmp.id <- rownames(tmp) tbl.EHS.combinedSetSubset.der <- fnCombineEHSs() tbl.EHS.combinedSetSubset.der <- tbl.EHS.combinedSetSubset.der[tmp.id,] paste("This subset represents ", format(round(dim(tmp)[1] / dim(tbl.CHM.outputs.raw)[1] * 100,2),big.mark=",",scientific=F), "% of UK dwelling stock / ") data.table::data.table(tbl.EHS.combinedSetSubset.der)
This examples selects unique cases based on a set of variables : floors, attic, cellar, attach, weight
tbl.EHS.combinedSetSubset.der <- fnCombineEHSs() unique.tmp <- fnCodeAttachmentSides(tbl.CHMwEHS.expandedEquivalised.der, div=" ::: ") unique.tmp <- unique.tmp[,c('floors','attic','cellar','attach','weight')] tmp.id <- NULL for(i in rownames(unique.tmp)){ tmp.id.tmp <- subset(tbl.CHMwEHS.expandedEquivalised.der, .floors == unique.tmp[i,'floors'] & .isattic == unique.tmp[i,'attic'] & .iscellar == unique.tmp[i,'cellar'] & .AttachState == unique.tmp[i,'attach'] & fpfullinc > 0, select = c('HousingCode')) tmp.id.tmp <- tmp.id.tmp[sample(dim(tmp.id.tmp)[1],1),] tmp.id <- rbind(tmp.id,tmp.id.tmp) } tmp.id <- as.integer(unlist(data.frame(tmp.id))) tbl.EHS.combinedSetSubset.der <- tbl.EHS.combinedSetSubset.der[tmp.id,] data.table::data.table(tbl.EHS.combinedSetSubset.der)
This examples emulates a common example of a cozy house, used in examples elsewhere. It contains:
- terraced house
- ~ 80 sqm
- 2 people
tmp <- subset(fnCombineEHSs(), .agl_floor_area < 85 & .agl_floor_area > 75) tbl.EHS.combinedSetSubset.der <- fnReducesEHSSubset(tmp, opt.DwellingType=as.character(lst.EnHub.TypologyConfigurations[["type"]][6,]), opt.Terrain=as.character(lst.EnHub.TypologyConfigurations[["terrain"]][1,]), opt.Tenure=as.character(lst.EnHub.TypologyConfigurations[["tenure"]][2,])) dim(tbl.EHS.combinedSetSubset.der) data.table::data.table(tbl.EHS.combinedSetSubset.der)