-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.R
78 lines (72 loc) · 1.83 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
# This is the server logic for a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://www.rstudio.com/shiny/
#
source("power.R")
library(shiny)
shinyServer(function(input, output) {
output$r2output <- renderText({
r2tof2(r2=input$r2value)
})
output$pwrPlot <- renderPlot({
# generate and plot an rnorm distribution with the requested
# number of observations
if(input$power == 0){
power <- NULL
}
else{
power <- input$power
}
if(input$dfs.plot == 0){
dfs.plot <- NULL
}
else{
dfs.plot <- input$dfs.plot
}
pwrFrame <- createPwrFrame(effectSizes=input$effectSize,
dfs=5:input$dfs,
dfNumerator=input$dfNumerator,
sig.level=input$sigLevel,
alternative=input$alternative,
test=input$test,
type=input$type,
standard=input$standard)
print(plotPower(pwrFrame,guides=input$guides,power=power,df=dfs.plot))
})
output$downloadButton <- downloadHandler(
filename = function(){
paste0("powerPlot.",as.character(input$plotFormat))
},
content = function(file){
if(input$power == 0){
power <- NULL
}
else{
power <- input$power
}
if(input$dfs.plot == 0){
dfs.plot <- NULL
}
else{
dfs.plot <- input$dfs.plot
}
pwrFrame <- createPwrFrame(effectSizes=input$effectSize,
dfs=5:input$dfs,
dfNumerator=input$dfNumerator,
sig.level=input$sigLevel,
alternative=input$alternative,
test=input$test,
type=input$type,
standard=input$standard)
if(input$plotFormat == "svg"){
svg(file,width=input$plotWidth,height=input$plotHeight)
}
else{
pdf(file,width=input$plotWidth,height=input$plotHeight)
}
print(plotPower(pwrFrame,guides=input$guides,power=power,df=dfs.plot))
dev.off()
}
)
})