-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.R
98 lines (84 loc) · 3.13 KB
/
server.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
# server ----
server <- function(input, output, session) {
# filter ui ----
# # student ID filter ----
# output$student_id_ui <- renderUI({
# selectizeInput("student_id",
# "Student ID:",
# choices = NULL,
# multiple = TRUE,
# options = list(maxOptions = 1000))
# })
#
# ## server side processing for student ID filter ----
# observe({
# updateSelectizeInput(session, "student_id",
# choices = unique(student_data$id),
# server = TRUE)
# })
## class level filter ----
output$class_ui <- renderUI({
selectizeInput("class_filter",
"Class Level:",
choices = unique(student_data$cl),
multiple = TRUE,
options = list(maxOptions = 1000))
})
## major filter ----
output$major_ui <- renderUI({
selectizeInput("major_filter",
"Major:",
choices = unique(student_data$major1_majortext),
multiple = TRUE,
options = list(maxOptions = 1000))
})
## major concentration filter ----
output$conc_ui <- renderUI({
selectizeInput("conc_filter",
"Concentration:",
choices = unique(student_data$major1_conctext),
multiple = TRUE,
options = list(maxOptions = 1000))
})
## department filter ----
output$dept_ui <- renderUI({
selectizeInput("dept_filter",
"Department:",
choices = unique(student_data$crs_dept),
multiple = TRUE,
options = list(maxOptions = 1000))
})
#*****************************************************************************
# reactive expressions (caches data for efficiency) ----
## filter logic ----
filtered_data <- reactive({
inc <- as.numeric(input$increment_filter)
max_gap <- as.numeric(input$max_gap_filter)
student_results <- gap_interval_matching(inc)
student_results <- filter_max_gap(student_results, max_gap)
student_results %>%
filter((term == input$term_filter) | (term == "full")) %>%
filter(if (input$day_filter != "All") days == input$day_filter
else TRUE) %>%
filter(length(input$student_id) == 0 |
id %in% input$student_id) %>%
filter(length(input$class_filter) == 0 |
cl %in% input$class_filter) %>%
filter(length(input$major_filter) == 0 |
major1_majortext %in% input$major_filter) %>%
filter(length(input$conc_filter) == 0 |
major1_conctext %in% input$conc_filter) %>%
filter(length(input$dept_filter) == 0 |
crs_dept %in% input$dept_filter)
})
## counts ----
term_counts <- reactive({
get_term_counts(filtered_data(), input$term_filter)
})
## heatmap ----
output$heatmap_plot <- renderPlotly({
p <- get_heatmap(term_counts(), input$term_filter)
ggplotly(p)
})
}
#*******************************************************************************