-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
64 lines (58 loc) · 2.84 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
source("Functions_14.R")
shinyServer(function(input, output) {
output$bayesfactors <- renderTable({
s2 <- as.numeric(unlist(strsplit(input$s2, split = ",")))
n <- as.numeric(unlist(strsplit(input$n, split = ",")))
hypotheses <- unlist(strsplit(gsub(" ", "", input$hypotheses), split = ";"))
log.BF <- input$log.BF
if (is.na(input$prior.probabilities)) {
prior.probabilities <- NA
} else {
prior.probabilities <- strsplit(gsub(" ", "", unlist(strsplit(input$prior.probabilities,
split = ","))), split = "/")
prior.probabilities <- sapply(prior.probabilities, function(x) if(length(x)==1) {as.numeric(x)}
else {as.numeric(x[1])/as.numeric(x[2])})
}
if (is.na(input$b)) {
b <- "default"
} else {
b <- strsplit(gsub(" ", "", unlist(strsplit(input$b, split = ","))), split = "/")
b <- sapply(b, function(x) if(length(x)==1) {as.numeric(x)} else
{as.numeric(x[1])/as.numeric(x[2])})
}
nsim <- if (is.na(input$nsim)) {100000} else {input$nsim}
seed <- if (is.na(input$seed)) {NA} else {input$seed}
results <- shiny.function(s2, n, hypotheses, log.BF, prior.probabilities, b, nsim, seed)[[1]]
colnames(results) <- 1:ncol(results)
return(results)
},
digits = 3, hover = TRUE, bordered = TRUE, colnames = TRUE, rownames = TRUE,
sanitize.rownames.function = function(x) paste('<b>',x,'</b>', sep ='')
)
output$posteriorprobabilities <- renderTable({
s2 <- as.numeric(unlist(strsplit(input$s2, split = ",")))
n <- as.numeric(unlist(strsplit(input$n, split = ",")))
hypotheses <- unlist(strsplit(gsub(" ", "", input$hypotheses), split = ";"))
log.BF <- input$log.BF
if (is.na(input$prior.probabilities)) {
prior.probabilities <- NA
} else {
prior.probabilities <- strsplit(gsub(" ", "", unlist(strsplit(input$prior.probabilities,
split = ","))), split = "/")
prior.probabilities <- sapply(prior.probabilities, function(x) if(length(x)==1) {as.numeric(x)}
else {as.numeric(x[1])/as.numeric(x[2])})
}
if (is.na(input$b)) {
b <- "default"
} else {
b <- strsplit(gsub(" ", "", unlist(strsplit(input$b, split = ","))), split = "/")
b <- sapply(b, function(x) if(length(x)==1) {as.numeric(x)} else
{as.numeric(x[1])/as.numeric(x[2])})
}
nsim <- if (is.na(input$nsim)) {100000} else {input$nsim}
seed <- if (is.na(input$seed)) {NA} else {input$seed}
results <- shiny.function(s2, n, hypotheses, log.BF, prior.probabilities, b, nsim, seed)[[2]]
},
digits = 3, hover = TRUE, bordered = TRUE, colnames = TRUE, rownames = FALSE
)
})