-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
79 lines (66 loc) · 2.35 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
source("data_management.R")
source("plots_by_sex.R")
shinyServer(function(input, output, session) {
# Define a reactive expression for the document term matrix
terms <- reactive({
# Change when the "update" button is pressed...
input$update
# ...but not for anything else
isolate({
withProgress({
setProgress(message = "Processing corpus...")
getTermMatrix(input$selection)
})
})
})
# Make the wordcloud drawing predictable during a session
wordcloud_rep <- repeatable(wordcloud)
bar_plot_reactive <- reactive({
create_bar_count_plot(cupid_data, input$over_bar_x, "count",
input$over_exclude_na)
})
density_plot_reactive <- reactive({
create_density_plot(cupid_data, input$density_x, "age",
input$density_exclude_na)
})
stack_plot_reactive <- reactive({
create_stacked_bar_plot(cupid_data, input$stack_x, input$stack_y,
input$exclude_na)
})
gender_plot_reactive <- reactive({
if (input$select_plot == "gender distribution") {
sex_dist
} else if (input$select_plot == "gender density") {
dens
} else if (input$select_plot == "number of people by age") {
age_graph
} else if (input$select_plot == "proportion of gender by age") {
proportion_age
} else if (input$select_plot == "mosaic plot") {
mosaic_plot
} else if (input$select_plot == "ethnicity by gender") {
gender_ethnicity
} else if (input$select_plot == "status by gender") {
gender_status
}
})
output$wordcloud <- renderPlot({
v <- terms()
wordcloud_rep(names(v), v, scale = c(5, 1),
min.freq = input$freq, max.words = input$max,
colors = brewer.pal(9, "RdBu")[-c(5, 6, 7)],
rot.per = 0.35)
})
output$stack_plot <- renderPlot({
stack_plot_reactive()
})
output$bar_plot <- renderPlot({
bar_plot_reactive()
})
output$density_plot <- renderPlot({
density_plot_reactive()
})
output$gender_plot <- renderPlot({
gender_plot_reactive()
})
})