Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(shiny)
- demo=data.frame(
- brand=c("a","a","a","a","a","a","b","b","b","b","b","c","c","c","c","c"),
- model=c("a11","a11","a21","a21","a31","a31","b55","b55","b56","b56","b56","c33","c34","c34","c33","c34"),
- tax=c("y","x","y","x","x","y","x","x","x","y","y","x","y","x","y","y"),
- seller=c("A","B","B","C","C","D","A","D","B","C","D","B","A","C","C","D"),
- price=c(1000,1100,1500,1400, 1200, 1300, 2000, 2200, 1900, 1800, 1700, 800, 900, 850, 950, 880),stringsAsFactors = F
- )
- runApp(list(
- ui = shinyUI(fluidPage(
- titlePanel("dynamic renderUI test"),
- sidebarLayout
- (
- sidebarPanel
- (width=3,
- selectInput("brand",label="my dynamic brand",choices=c("all","a","b","c"),selected="all"),
- uiOutput("ui1"),
- uiOutput("ui2"),
- uiOutput("ui3")
- ),
- mainPanel
- (
- navbarPage(
- title="",
- tabPanel("dynamic table test",dataTableOutput("table"))
- )
- )
- )))
- , server = function(input, output) ({
- output$ui1=renderUI({
- selectInput("model","select the model",choices=c("all",sort(unique(demo[demo$model==input$model]$model))))
- })
- output$ui2=renderUI({
- selectInput("tax","select the tax",choices=c("all",sort(unique(demo[demo$tax==input$tax]$tax))))
- })
- output$ui3=renderUI({
- selectInput("seller","select the seller",choices=c("all",sort(unique(demo[demo$seller==input$seller]$seller))))
- })
- output$table=renderTable({
- demo
- })
- })
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement