-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_server.R
203 lines (179 loc) · 6.73 KB
/
my_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
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
source('wrangle3.R')
source('wrangle4.R')
source('wrangle2.R')
my_server <- function(input, output) {
output$q1_page <- renderPrint({
filename <- input$q1_select
filename <- sub('Introduction', 'intro', filename)
filename <- sub('Computer Science', 'cs', filename)
filename <- sub('Business', 'bu', filename)
filename <- sub('Conclusion', 'conc', filename)
includeHTML(paste0('./www/pages/', filename, '.html'))
})
output$q1_subsec <- renderPrint({
filename <- input$q1_select
filename <- sub('Computer Science', 'cs', filename)
filename <- sub('Business', 'bu', filename)
type <- input$q1_type
type <- substr(type, nchar(type), nchar(type))
includeHTML(paste0('./www/pages/', filename, type, '.html'))
})
# Renders a plot with the selected years in the x axis and the area in the y axis
#if(input$school_select_high == "University of Washington") {
output$uw_high <- renderPlot ({
uw_high_plot <- ggplot(data = uw_distinct_high) +
geom_col(mapping = aes(x = Department, y = `Number of Classes`), fill = "#8856a7") +
labs(
title = "Departments at UW with High Class GPAs (GPA >= 3.8)",
x = "Departments",
y = "Number of Classes"
) +
theme(plot.title = element_text(hjust = 0.5))
uw_high_plot
})
# } else {
output$vt_high <- renderPlot ({
vt_high_plot <- ggplot(data = vt_distinct_high) +
geom_col(mapping = aes(x = Department, y = `Number of Classes`), fill = "#99000d") +
labs(
title = "Departments at VT with High Class GPAs (GPA >= 3.8)",
x = "Departments",
y = "Number of Classes"
) +
theme(plot.title = element_text(hjust = 0.5))
vt_high_plot
})
#}
output$uw_low <- renderPlot ({
uw_low_plot <- ggplot(data = uw_distinct_low) +
geom_col(mapping = aes(x = Department, y = `Number of Classes`), fill = "#8856a7") +
labs(
title = "Departments at UW with High Class GPAs (GPA <= 2.8)",
x = "Departments",
y = "Number of Classes"
) +
theme(plot.title = element_text(hjust = 0.5))
uw_low_plot
})
output$vt_low <- renderPlot ({
vt_low_plot <- ggplot(data = vt_distinct_low) +
geom_col(mapping = aes(x = Department, y = `Number of Classes`), fill = "#99000d") +
labs(
title = "Departments at VT with High Class GPAs (GPA <= 2.8)",
x = "Departments",
y = "Number of Classes"
) +
theme(plot.title = element_text(hjust = 0.5))
vt_low_plot
})
output$q4plot <- renderPlot({
if (input$subject == "Math"){
uw_summary <- uw %>%
filter(Subject %in% c("MATH", "AMAT", "STAT")) %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "University of Washington")
vt_summary <- virginia_tech %>%
filter(Subject %in% c("MATH", "STAT")) %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "Virginia Tech")
} else if (input$subject == "Science"){
uw_summary <- uw %>%
filter(Subject %in% c("BIOL", "CHEM", "PHYS")) %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "University of Washington")
vt_summary <- virginia_tech %>%
filter(Subject %in% c("BIOL", "CHEM", "PHYS")) %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "Virginia Tech")
} else if (input$subject == "English"){
uw_summary <- uw %>%
filter(Subject == "ENGL") %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "University of Washington")
vt_summary <- virginia_tech %>%
filter(Subject == "ENGL") %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "Virginia Tech")
} else if (input$subject == "Social Science"){
uw_summary <- uw %>%
filter(Subject %in% c("COM ", "SOC ", "PSYC")) %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "University of Washington")
vt_summary <- virginia_tech %>%
filter(Subject %in% c("COMM", "SOC ", "PSYC")) %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "Virginia Tech")
} else {
uw_summary <- uw %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "University of Washington")
vt_summary <- virginia_tech %>%
group_by(Size) %>%
summarize( Average_GPA = mean(Average_GPA)) %>%
mutate(School = "Virginia Tech")
}
combined_data <- full_join(uw_summary, vt_summary, by = c("Size", "Average_GPA", "School"))
positions <- c("Less than 25", "25-50", "Greater than 50")
ggplot(data = combined_data, aes(x = Size, y = Average_GPA, fill = School)) +
geom_bar(stat="identity", position=position_dodge()) +
scale_x_discrete(limits = positions) +
scale_fill_manual(values = c('#8856a7','#99000d')) +
labs(title = paste0("GPA Based on Class Size for ", input$subject), y = "Average GPA") +
theme(plot.title = element_text(hjust = 0.5))
})
output$uw_graph_q3 <- renderPlot({
uw_graph <- ggplot(summary_uw_grades,
mapping = aes(
x = Subject,
y = avg_gpa,
fill = teaches_multiple
)
) +
geom_col(position = "dodge") +
labs(
title = "University of Washington Average Subjectal Grades for
Professors Teaching a Single Course vs Multiple Courses",
x = "Subject",
y = "Grade Point Average",
fill = "Teaches Multiple Courses"
) +
scale_x_discrete(labels = c(
"Biology", "Chemistry", "Computer Science",
"Informatics", "Math", "Physics"
)) +
scale_fill_manual(values = c("#8856a7", "gold"))
uw_graph
})
output$vt_graph_q3 <- renderPlot({
vt_graph <- ggplot(summary_vt_grades,
mapping = aes(
x = Subject,
y = avg_gpa,
fill = teaches_multiple
)
) +
geom_col(position = "dodge") +
labs(
title = "Virginia Tech Average Subject Grades for Professors
Teaching a Single Course vs Multiple Courses",
x = "Subject",
y = "Grade Point Average",
fill = "Teaches Multiple Courses"
) +
scale_x_discrete(labels = c(
"Biology", "Chemistry", "Computer Science",
"Math", "Physics"
)) +
scale_fill_manual(values = c("#99000d", "#E87722"))
vt_graph
})
}