Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
woRkflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tom Rushby
woRkflow
Commits
f7b5c371
Commit
f7b5c371
authored
4 years ago
by
Tom Rushby
Browse files
Options
Downloads
Patches
Plain Diff
Tidy up.
parent
08c66416
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
howTo/openGeogAPI/local_auth_ghg_plots.R
+14
-32
14 additions, 32 deletions
howTo/openGeogAPI/local_auth_ghg_plots.R
with
14 additions
and
32 deletions
howTo/openGeogAPI/local_auth_ghg_plots.R
+
14
−
32
View file @
f7b5c371
...
...
@@ -42,35 +42,21 @@ download.file(url_to_get, tempf, method = "curl")
dt
<-
readxl
::
read_xlsx
(
tempf
,
sheet
=
"Full dataset"
,
skip
=
1
)
# Functions
(REDUNDANT)
----
# Functions ----
lvl_detail
<-
"high"
filter_detail
<-
function
(
lvl_detail
=
lvl_detail
){
if
(
lvl_detail
==
"low"
){
ghg_subset
<-
function
(
dt
,
auth_area
=
"Southampton"
){
dt
<-
dt
%>%
filter
(
Name
%in%
las_to_load
)
%>%
select
(
`CTRY18NM/RGN18NM`
,
`Second Tier Authority`
,
Name
,
Code
,
Year
,
`Industry and Commercial Total`
,
`Domestic Total`
,
`Transport Total`
,
`LULUCF Net Emissions`
)
filter
(
dt
$
Name
%in%
auth_area
)
# add filter for categories with input$
}
if
(
lvl_detail
==
"high"
){
dt
<-
dt
%>%
filter
(
Name
%in%
las_to_load
)
%>%
select
(
`CTRY18NM/RGN18NM`
,
`Second Tier Authority`
,
Name
,
Code
,
Year
,
`A. Industry and Commercial Electricity`
,
`B. Industry and Commercial Gas`
,
`C. Large Industrial Installations`
,
`D. Industrial and Commercial Other Fuels`
,
`E. Agriculture`
,
`F. Domestic Electricity`
,
`G. Domestic Gas`
,
`H. Domestic 'Other Fuels'`
,
`I. Road Transport (A roads)`
,
`J. Road Transport (Motorways)`
,
`K. Road Transport (Minor roads)`
,
`L. Diesel Railways`
,
`M. Transport Other`
,
`LULUCF Net Emissions`
)
}
ghg_emissions
<-
melt
(
dt
,
id.vars
=
c
(
"CTRY18NM/RGN18NM"
,
"Second Tier Authority"
,
"Name"
,
"Code"
,
"Year"
))
return
(
ghg_emissions
)
ghg_subset2
<-
function
(
dt
,
auth_area
=
"Southampton"
){
dt
<-
dt
%>%
filter
(
dt
$
Name
%in%
auth_area
,
dt
$
Year
==
plot_year
)
# add filter for categories with input$
}
...
...
@@ -127,11 +113,7 @@ las_to_load <- c(las_to_load, " Hampshire (Average)") # add Hampshire average to
auth_area
<-
" Hampshire (Average)"
# Use to set auth_area manually (outside of loop)
ghg_subset
<-
function
(
dt
,
auth_area
=
"Southampton"
){
dt
<-
dt
%>%
filter
(
dt
$
Name
%in%
auth_area
)
# add filter for categories with input$
}
# Construct plots ----
plotCaption
=
paste0
(
"Emissions data: Department for Business, Energy & Industrial Strategy"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment