-
Notifications
You must be signed in to change notification settings - Fork 1
/
water_dashboard.Rmd
120 lines (91 loc) · 2.92 KB
/
water_dashboard.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
title: "Water Data"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: https://github.com/ucd-cwee/greengov-challenge
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard, quietly = TRUE)
library(rgdal, quietly = TRUE)
# load data
util_summary <- readRDS('data/util_summary.rds')
water_byMonth <- readRDS('data/water_byMonth.rds')
water_districts <- readRDS('data/water_districts.rds')
# load and call modules
source('modules/water_district_map.R')
util <- callModule(waterConservation, "water_districts", water_summary = util_summary,
water_monthly = water_byMonth, map_data = water_districts,
id_field = 'PWS_ID', name_field = 'PWS_name')
savings <- reactive({
util() %>%
filter(selected) %>%
mutate(change_1000m3 = (gal_2013 - gal_cur) / 264172.052) %>%
group_by(PWS_ID) %>%
summarise(proportionChangeGoal = mean(proportionChangeGoal),
gal_2013 = sum(gal_2013),
gal_cur = sum(gal_cur)
) %>%
mutate(change_gal = gal_2013 - gal_cur,
change_prop = change_gal / gal_2013,
sav_diff = proportionChangeGoal - change_prop,
change_1000m3 = change_gal / 264172.052,
kWh_saved = change_1000m3 * util_summary$ei_kWh_1000m3[match(PWS_ID, util_summary$PWS_ID)],
MWh_saved = kWh_saved / 1e3,
kg_CO2e_saved = MWh_saved * util_summary$ghgFactor_kg_MWh[match(PWS_ID, util_summary$PWS_ID)])
})
```
Sidebar {.sidebar}
=======================================================================
### Water Utilities
```{r}
waterConservationInput1('water_districts')
div(style = "margin: 0px 5px", waterConservationInput2('water_districts'))
```
Conservation
=======================================================================
Row
-----------------------------------------------------------------------
### Water Savings {.value-box}
```{r}
# water savings
renderValueBox({
sprintf('%.1f%% (goal: %.f%%)', savings()$change_prop * 100, savings()$proportionChangeGoal * 100)
})
```
### Missed Conservation Standard by {.value-box}
```{r}
# Missed Conservation Standard by
renderValueBox({
sprintf('%.1f%%', savings()$sav_diff * 100)
})
```
### Energy Savings (kWh energy) {.value-box}
```{r}
# Energy Savings (kWh energy)
renderValueBox({
format(round(savings()$kWh_saved), big.mark=",", scientific=FALSE)
})
```
### GHG Emissions (kg CO2e) {.value-box}
```{r}
# GHG emissions (kg CO2e)
renderValueBox({
format(round(savings()$kg_CO2e_saved), big.mark=",", scientific=FALSE)
})
```
Row
-----------------------------------------------------------------------
### {.nopadding}
```{r}
waterConservationOutput1('water_districts')
```
### {.nopadding}
```{r}
waterConservationOutput2('water_districts')
```
Water Quality
=======================================================================
### Water Quality