-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
212 lines (212 loc) · 7.44 KB
/
.Rhistory
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
shiny::runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-JustBreathe')
shiny::runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
shiny::runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
shiny::runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
?dashboardSidebar
?colorNumeric
runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
runApp('UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake')
# libraries
library(shiny)
library(devtools)
library(ggplot2)
library(shinydashboard)
library(scales) # needed for percent function
library(shinythemes) # themes for bootstrapPage, fluidPage, navbarPage, or fixedPage
library(dashboardthemes)
library(ggthemes)
library(shinyalert)
library(leaflet)
library(rgdal)
library(geojson)
library(geojsonio)
library(colourpicker)
library(shinyWidgets)
library(viridis) # Color palette
library(cdlTools) # convert FIPS codes into names
library(htmltools) # to use htmlEscape function
library(plotly)
library(RColorBrewer)
library(reshape2)
library(fst)
library(future)
library(data.table)
# importing datasets
setwd("./csv/")
temp = list.files(pattern="*.csv")
datasets = lapply(temp, read.csv)
dataset <- do.call(rbind, datasets)
setwd("../")
daily_df <- read_fst("fst/daily_all_aqi_by_county.fst")
names(daily_df) <- c("state","county","aqi","category","pollutant","year","month","day")
daily_all <- read_fst("fst/daily_all_pollutants_2018.fst")
hourly_df <- read_fst("fst/hourly_all_data_2018.fst")
# needed for counties coordinates
sites <- fread(file = "sites/aqs_sites.csv", sep=",",header = TRUE)
# geojson file for counties shape
f_xy <- future({
xy <- geojsonio::geojson_read("gz_2010_us_050_00_20m.json", what = "sp")
# Since the xy has factored FIPS code for state instead of names, converting them in numeric and then
# getting the names
converted_states_names <- fips(as.numeric(levels(xy$STATE))[xy$STATE],to="name")
xy$STATENAME<-converted_states_names
xy
}) %plan% multiprocess
########################################### PREPROCESSING #########################################
years<-c(1980:2018)
H_years<-c(2018) #years available for hourly data
H_months<-c("January","February","March","April","May","June","July","August","September","October","November","December")
H_days<-c(1:31)
states<-unique(dataset$State)
t<-subset(dataset, State == 'Illinois')
counties<-unique(t$County)
pollutants <- c("CO","NO2","Ozone","SO2","PM2.5","PM10")
pollutants_2 <- c("PM2.5","PM10","CO","NO2","Ozone","SO2")
statistics <- c("Median","Max","90th percentile")
# All counties with state
all_counties <- c()
for(s in states){
coun <- subset(dataset, State == s)
counti<-unique(coun$County)
counti <- paste(counti,"-",s)
all_counties <- c(all_counties,counti)
}
############################################################ ITALY ########################################################################################
italy_df <- read_fst("italy/daily_italy.fst")
cities_italy <- levels(unique(italy_df$city)) #preprocess data such that capitalization is proper
setwd("/Users/mirkomantovani/UIC/Visualization and Visual Analytics/VisualAnalytics-EveryBreathYouTake/")
# libraries
library(shiny)
library(devtools)
library(ggplot2)
library(shinydashboard)
library(scales) # needed for percent function
library(shinythemes) # themes for bootstrapPage, fluidPage, navbarPage, or fixedPage
library(dashboardthemes)
library(ggthemes)
library(shinyalert)
library(leaflet)
library(rgdal)
library(geojson)
library(geojsonio)
library(colourpicker)
library(shinyWidgets)
library(viridis) # Color palette
library(cdlTools) # convert FIPS codes into names
library(htmltools) # to use htmlEscape function
library(plotly)
library(RColorBrewer)
library(reshape2)
library(fst)
library(future)
library(data.table)
# importing datasets
setwd("./csv/")
temp = list.files(pattern="*.csv")
datasets = lapply(temp, read.csv)
dataset <- do.call(rbind, datasets)
setwd("../")
daily_df <- read_fst("fst/daily_all_aqi_by_county.fst")
names(daily_df) <- c("state","county","aqi","category","pollutant","year","month","day")
daily_all <- read_fst("fst/daily_all_pollutants_2018.fst")
hourly_df <- read_fst("fst/hourly_all_data_2018.fst")
# needed for counties coordinates
sites <- fread(file = "sites/aqs_sites.csv", sep=",",header = TRUE)
# geojson file for counties shape
f_xy <- future({
xy <- geojsonio::geojson_read("gz_2010_us_050_00_20m.json", what = "sp")
# Since the xy has factored FIPS code for state instead of names, converting them in numeric and then
# getting the names
converted_states_names <- fips(as.numeric(levels(xy$STATE))[xy$STATE],to="name")
xy$STATENAME<-converted_states_names
xy
}) %plan% multiprocess
########################################### PREPROCESSING #########################################
years<-c(1980:2018)
H_years<-c(2018) #years available for hourly data
H_months<-c("January","February","March","April","May","June","July","August","September","October","November","December")
H_days<-c(1:31)
states<-unique(dataset$State)
t<-subset(dataset, State == 'Illinois')
counties<-unique(t$County)
pollutants <- c("CO","NO2","Ozone","SO2","PM2.5","PM10")
pollutants_2 <- c("PM2.5","PM10","CO","NO2","Ozone","SO2")
statistics <- c("Median","Max","90th percentile")
# All counties with state
all_counties <- c()
for(s in states){
coun <- subset(dataset, State == s)
counti<-unique(coun$County)
counti <- paste(counti,"-",s)
all_counties <- c(all_counties,counti)
}
############################################################ ITALY ########################################################################################
italy_df <- read_fst("italy/daily_italy.fst")
cities_italy <- levels(unique(italy_df$city)) #preprocess data such that capitalization is proper
View(dataset)
a <- subset(dataset, State='Illinois', County='Cook', Year = 2018)
View(a)
a <- subset(dataset, State='Illinois', County='Cook', Year = 2018)
a <- subset(dataset, State='Illinois', County='Cook')
sub<-subset(dataset, Year == 2018)
View(sub)
sub<-subset(sub, State = 'Illinois')
sub<-subset(sub, State = "Illinois")
View(sub)
sub<-subset(dataset, Year == 2017)
a <- subset(dataset, State=='Illinois', County=='Cook', Year == 2018)
a <- subset(dataset, State=='Illinois', County=='Cook', Year == 2018)
a <- subset(dataset, State=='Illinois', County=='Cook')
View(a)
sub<-subset(dataset, Year == 2018)
View(sub)
sub<-subset(sub, County == "Cook")
sub<-subset(dataset, Year == 2018)
View(sub)
sub$sel_feat<-sub[["Days.SO2"]]/sub$Days.with.AQI*100
View(sub)
sub2 <- sub[order(sub$sel_feat,decreasing = TRUE),]
View(sub2)
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
?sliderInput
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()