/
shiny_test.clj
38 lines (33 loc) · 1 KB
/
shiny_test.clj
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
(ns clojuress.v1.shiny-test
(:require [clojuress.v1.r :as r :refer [r]]
[clojuress.v1.util :refer [l]]
[clojuress.v1.require :refer [require-r]]))
(require-r '[base]
'[shiny :as s])
;; Shiny's hello-world
;; https://shiny.rstudio.com/gallery/example-01-hello.html
;; Run this, and browse the url printed at the REPL.
(comment
(r.base/print
(s/shinyApp
(s/shinyUI
(s/fluidPage
(s/titlePanel "Hello Shiny!")
(s/sidebarLayout
(s/sidebarPanel
(s/sliderInput
"obs"
"Number of observations"
:min 1
:max 1000
:value 500))
(s/mainPanel
(s/plotOutput "distPlot")))))
(s/shinyServer
(r '(function [input output]
(<- output$distPlot
(renderPlot (hist (rnorm input$obs))))))))))
;; To get the session to respond again, Ctrl+C at your REPL,
;; and then discard the current session running the Shiny app:
(comment
(r/discard-default-session))