forked from byandell/shiny_module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_renderUI.R
39 lines (34 loc) · 867 Bytes
/
module_renderUI.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
library(shiny)
## Basic module including renderUI of slider.
## Shows argument to and return from sliderText() server logic.
sliderTextUI <- function(id) {
ns <- NS(id)
tagList(
uiOutput(ns("set_slider")),
textOutput(ns("number"))
)
}
sliderText <- function(input, output, session, show) {
ns <- session$ns
output$set_slider <- renderUI({
sliderInput(ns("slider"), "Slide me", 0, 100, 5)
})
output$number <- renderText({
if(show())
input$slider
else
NULL
})
reactive({input$slider + 5})
}
ui <- fluidPage(
checkboxInput("display", "Show Value"),
sliderTextUI("module"),
h2(textOutput("value"))
)
server <- function(input, output) {
display <- reactive({input$display})
num <- callModule(sliderText, "module", display)
output$value <- renderText({paste0("slider1+5: ", num())})
}
shinyApp(ui, server)