-
Notifications
You must be signed in to change notification settings - Fork 0
/
version 1.R
117 lines (89 loc) · 4.2 KB
/
version 1.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
library(plotly)
library(rgdal)
library(shinydashboard)
library(reshape2)
library(shinythemes)
library(DT)
library(ggplot2)
library(tools)
library(stringr)
library(shiny)
library(leaflet)
library(dplyr)
library(leaflet.extras)
library(jsonlite)
#import and clean data
text<-na.omit(read.csv("/Users/tiangeyang/Desktop/R Shiny/Texting_Zone_Locations.csv"))
hudson<-na.omit(read.csv("/Users/tiangeyang/Desktop/R Shiny/Hudson_River_Park_Public_Facilities___Points_of_Interest.csv"))
golf<-na.omit(read.csv("/Users/tiangeyang/Desktop/R Shiny/Golf_Courses.csv"))
fishing<-na.omit(read.csv("/Users/tiangeyang/Desktop/R Shiny/Recommended_Fishing_Lakes_and_Ponds.csv"))
# Avoid plotly issues
pdf(NULL)
# Application header & title
header <- dashboardHeader(title = "Some interesting places in New York", titleWidth = 400)
# Sidebar
sidebar <- dashboardSidebar(width = 250,
sidebarMenu(
id = "tabs",
# Menu Items ----------------------------------------------
menuItem("Map", icon = icon("map-pin"), tabName = "map"),
menuItem("Chart", icon = icon("bar-chart"), tabName = "chart"),
menuItem("Table", icon = icon("table"), tabName = "table"),
# Inputs: select county to find location for golf court
selectInput(inputId = "county",
label = "Select county to find location",
choices = sort(unique(golf$County)),
selected = "Suffolk"),
# Inputs: select boat launch type to plot for fishing places
checkboxGroupInput(inputId = "type",
label = "Select operation type to view",
choices = sort(unique(fishing$Boat.Launch.Type)),
selected = c("Hand Launch","Trailer Improved")),
# # Select sample size
numericInput(inputId = "n_samp",
label = "Select number to view:",
min = 1, max = nrow(text),
value = 50),
# Download Button--------------------------------------------------------
downloadButton("downloadData", "Download Data Here")
)
)
# Dashboard Window
body <- dashboardBody(tabItems(
# Map
tabItem("map",
fluidRow(
tabBox(width = 14,
leafletOutput("It Is A Map")
))),
# Graph
tabItem("chart",
fluidRow(
tabBox(width = 14,
tabPanel("size of fishing area", plotlyOutput("plot fishing area")))
)),
tabItem("table",
fluidPage(
box(title = "It Is A Datatable", DT::dataTableOutput("table"), width = 14)))
)
)
ui <- dashboardPage(header, sidebar, body, skin = "purple")
# Define server function required to create plots and value boxes -----
server <- function(input, output) {
# Reactive data function for golf
golf.subset <- reactive({
#District Filter
golf <- subset(golf, County %in% input$county)
# Return dataframe ----------------------------------------------
return(golf)
})
# Reactive data function for fishing
fishing.subset <- reactive({
#District Filter
fishing <- subset(fishing, Boat.Launch.Type%in% input$type)
# Return dataframe ----------------------------------------------
return(fishing)
})
}
# Run the application
shinyApp(ui = ui, server = server)