-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
124 lines (94 loc) · 2.89 KB
/
app.R
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
# CS 424 - Project 2
# Fatima Qarni & Manny Martinez
#libraries to include
library(shiny)
library(shinydashboard)
library(ggplot2)
library(lubridate)
library(DT)
library(jpeg)
library(grid)
library(leaflet)
library(scales)
source('graphYearsInput.R')
source('mapYearsInput.R')
source('graphHourlyInput.R')
source('dataModel.R')
#this data gets passed to the graphYears input so that we can dynamically update the list of counties
#when a new state is selected
daily <- load(file = "daily_data/daily_aqi_by_county_1990.Rdata")
NameListData <- get(daily[ls() != "fileName"])
year_list <- c(1990:2018)
state_list <- unique(as.vector(NameListData$`State Name`))
county_list <- unique(as.vector(NameListData$`county Name`))
# Define UI
ui <- dashboardPage(
dashboardHeader(title = "CS 424 - Project 2 - Fatima Qarni & Manny Martinez",
tags$li(
actionLink("openInfo", label = " Project Info", icon = icon("info")),
class = "dropdown"
)),
dashboardSidebar(
disable = FALSE,
collapsed = FALSE,
sidebarMenu(
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
menuItem("GraphsYears", tabName = "graphsYears"),
menuItem("GraphsHourly", tabName = "graphsHourly"),
menuItem("Map", icon = icon("th"), tabName = "mapYears")
)
),
dynamicBody <- dashboardBody(
tabItems(
tabItem(tabName = "graphsYears",
graphYearsInput("graphyears", year_list, state_list, county_list)
),
tabItem(tabName = "graphsHourly",
graphHourlyInput("graphhourly", state_list, county_list)
),
tabItem(tabName = "mapYears",
#mapYearsInput(year_list, state_list)
mapYearsInput("mapyears",year_list, state_list)
)
)
),
dashboardBody(
#graphYearsInput(year_list)
dynamicBody
)
)
# Define server logic required to draw a charts ----
server <- function(input, output) {
gy <- callModule(graphYears, "graphyears", NameListData )
gh <- callModule(graphHourly, "graphhourly")
my <- callModule(mapYears, "mapyears")
observeEvent(input$openInfo, {
showModal(modalDialog(
title = "Fatima Qarni & Emmanuel Martinez",
p(
"Libraries used for visualization: shiny, shinydashboard, ggplot2, lubridate, DT, jpeg, grid, leaflet, and scales. \n
The data is from: https://aqs.epa.gov/aqsweb/airdata/download_files.html
Reference for map visualization: https://rstudio.github.io/leaflet/choropleths.html &
https://franciscorequena.com/blog/how-to-make-an-interactive-map-of-usa-with-r-and-leaflet/"
)
))
})
}
shinyApp(ui = ui, server = server)