-
Notifications
You must be signed in to change notification settings - Fork 8
/
server.R
executable file
·72 lines (68 loc) · 1.96 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
#setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
library(shiny)
library(ggplot2)
source("GenerateRGraphs.R")
# Define server logic required to draw a histogram
function(input, output) {
reRunSimulation <- reactive({
# Change when the "update" button is pressed...
input$update
# ...but not for anything else
isolate({
withProgress({
setProgress(message = paste("Running", input$simulations, "MC Simulations..."))
LoadData(
type = input$variable,
M = input$simulations,
N = input$N,
p = input$prob,
theta = input$theta,
gamma = input$gamma, assets = input$assets
)
})
})
})
reRunSimulation2 <- reactive({
# Change when the "update" button is pressed...
input$update2
# ...but not for anything else
isolate({
GenerateSimulationData(
N = input$N2,
p = input$prob2,
theta = input$theta2,
gamma = input$gamma2,
assets = input$assets2
)
})
})
output$plot <- renderPlot({
reRunSimulation()
PlotMC(input$variable,
xlab = expression(gamma),
plotType = 'D')
}, height = 400, width = 600)
output$plot2 <- renderPlot({
reRunSimulation()
PlotMC(input$variable,
plotType = 'L')
}, height = 400, width = 600)
output$entropyPlot <- renderPlot({
reRunSimulation()
PlotMC(input$variable,
plotType = 'E')
}, height = 400, width = 600)
output$plot3 <- renderPlot({
reRunSimulation2()
simulateforbanki(input$snapshot%%GetIterations())
}, width = 750, height=800)
output$downloadData <- downloadHandler(
filename = function() { paste('simulation_',input$snapshot%%GetIterations(), sep='') },
content = function(file) {
png(file="simulations.png")
simulateforbanki(input$snapshot%%GetIterations())
dev.off()
file.copy("simulations.png", file, overwrite=TRUE)
}
)
}