-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathapp.R
More file actions
58 lines (49 loc) · 1.24 KB
/
app.R
File metadata and controls
58 lines (49 loc) · 1.24 KB
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
library(shiny)
#' Reactively render arbitrary JSON object data.
#'
#' This is a generic renderer that can be used to render any Jsonifiable data.
#' The data goes through shiny:::toJSON() before being sent to the client.
render_json <- function(
expr,
env = parent.frame(),
quoted = FALSE,
outputArgs = list(),
sep = " "
) {
func <- installExprFunction(expr, "func", env, quoted, label = "render_json")
createRenderFunction(
func,
function(value, session, name, ...) {
value
},
function(...) {
stop("Not implemented")
},
outputArgs
)
}
server <- function(input, output, session) {
histogram_data <- reactive({
req(input$bins)
x <- faithful$waiting
breaks <- round(seq(min(x), max(x), length.out = input$bins + 1), 1)
dist <- hist(x, breaks = breaks, plot = FALSE)
list(
breaks = breaks,
counts = dist$counts,
ticks = pretty(breaks)
)
})
output$histogram_data <- render_json({
histogram_data()
})
}
ui <- function() {
htmlTemplate("dist/index.html")
}
# Serve the JS and CSS assets under /assets
if (!dir.exists("dist/assets")) {
stop("Missing static assets directory at dist/assets")
}
addResourcePath("assets", "dist/assets")
shinyApp(ui, server)