-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshinyapptesting.Rmd
143 lines (108 loc) · 3.06 KB
/
shinyapptesting.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
---
title: "rshinyapp"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(shiny)
library(leaflet)
library(spData)
library(dplyr)
```
```{r}
# Define UI for application that filters map points based on year and minimum population
ui <- fluidPage(
# Application title
titlePanel("CPS Attendance"),
# Sidebar with a slider input for year, numeric input for population
sidebarLayout(
sidebarPanel(
sliderInput("Student_Attendance_Year_1_Pct",
"percent attendance",
min = 0,
max = 100,
step = 10,
sep = "",
value = .5),
numericInput("pop_min",
"Minimum Population (in millions)",
min = 1,
max = 20,
value = 10)
),
# Show the map and table
mainPanel(
plotOutput("distPlot"),
leafletOutput("map"),
dataTableOutput("table")
)
)
)
# Define server logic required to draw a map and table
server <- function(input, output) {
output$map <- renderLeaflet({
pop_by_year <- filter(urban_agglomerations,
year == input$year,
population_millions > input$pop_min)
leaflet(data = pop_by_year) %>%
addTiles() %>%
addMarkers()
})
output$table <- renderDataTable({
pop_by_year <- filter(urban_agglomerations,
year == input$year,
population_millions > input$pop_min)
pop_by_year
})
}
# Run the application
shinyApp(ui = ui, server = server)
```
```{r}
ui <- fluidPage(
# Application title
titlePanel("CPS Tier Map"),
# Sidebar with a slider input for year, numeric input for population
sidebarLayout(
sidebarPanel(
sliderInput("year",
"Year",
min = 1950,
max = 2030,
step = 5,
sep = "",
value = 1950),
numericInput("pop_min",
"Minimum Population (in millions)",
min = 1,
max = 20,
value = 10)
),
# Show the map and table
mainPanel(
plotOutput("distPlot"),
leafletOutput("map"),
dataTableOutput("table")
)
)
)
# Define server logic required to draw a map and table
server <- function(input, output) {
output$map <- renderLeaflet({
pop_by_year <- filter(urban_agglomerations,
year == input$year,
population_millions > input$pop_min)
leaflet(data = pop_by_year) %>%
addTiles() %>%
addMarkers()
})
output$table <- renderDataTable({
pop_by_year <- filter(urban_agglomerations,
year == input$year,
population_millions > input$pop_min)
pop_by_year
})
}
# Run the application
shinyApp(ui = ui, server = server)
```