Skip to content

Instantly share code, notes, and snippets.

@skohari
Created October 5, 2018 14:27
Show Gist options
  • Save skohari/419bbc8816c9f97a52d00dd04ff5c42e to your computer and use it in GitHub Desktop.
Save skohari/419bbc8816c9f97a52d00dd04ff5c42e to your computer and use it in GitHub Desktop.
renderUI2.r
library(shiny)##########################################################################
ui <- fixedPage(
h2("Normal example"),
uiOutput("moreControls"),
uiOutput("moreControls1"),
uiOutput("test")
)
server <- function(input, output, session) {
output$moreControls <- renderUI({
tagList(
sliderInput("n", "N", 1, 10, 4),
numericInput("nlabel1", "Label", 67)
)
})
output$moreControls1 <- renderUI({
tagList(
numericInput("nlabel1", "Label", input$n)
)
})
output$test <- renderUI({
lapply(1:input$n, function(val) {
numericInput(paste0("label", val, sep = ""), paste("label", val, sep = " "), val)
})
})
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment