-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.R
69 lines (48 loc) · 1.7 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
library(shiny)
library(ggplot2)
library(dplyr)
library(broom)
# Define server logic
shinyServer(function(input, output, session) {
df <- data.frame()
output$Plot <- renderPlot({
if (is.null(input$variable))
return(NULL)
ifelse(is.numeric(df[,as.character(input$variable)]),
return(ggplot(aes_string(x = input$variable), data = df) +
geom_histogram(bins = input$bins) + theme_minimal() +
scale_x_continuous(limits = c(input$xmin, input$xmax))
),
return(ggplot(aes_string(x = input$variable), data = df) +
geom_bar() + theme_minimal()))
})
output$condPanel <- renderUI({
if (is.null(input$variable))
return(NULL)
if (is.numeric(df[,as.character(input$variable)])){
fluidRow(
column(3,
sliderInput(
"bins",
"Number of bins:",
min = 1,
max = 50,
value = 30
)),
column(4, offset = 1, numericInput("xmin", label = "X min", value = NULL)),
column(4, numericInput("xmax", label = "X max", value = NULL)))
}
})
output$dataframe <- renderDataTable({
inFile <- input$datafile
if (is.null(inFile))
return(NULL)
df <<- read.csv(inFile$datapath)
updateSelectizeInput(session, "variable",
choices = c("Write here" = "", names(df)), selected = names(df)[1])
df
}, options = list(scrollX = T, pageLength = 5))
output$stat_summary <- renderDataTable({
summary(df[,as.character(input$variable)]) %>% tidy
}, options = list(dom = 't', searching = F))
})