小编Ran*_*ann的帖子

闪亮的应用程序checkboxInput和conditionalPanel

我是ShinyApp的新手.

我想使用带有conditionalPanel的checkboxInput(),所以当它被选中时,将显示Type的选项(然后用户可以从"BEER","REFRESHMENT","SPIRITS","WINE"中选择一个Type).如果未选中,则不会显示"类型"选项.

下面是我的代码,但是当Type选项没有显示时,无论我是否选中该框.我想我应该在服务器功能中写一些东西?我真的不知道.谢谢您的帮助.

  ui <- fluidPage(
        titlePanel("BC Liquor Store prices"),
        img(src = "BCLS.png",align = "right"),
        sidebarLayout(
             sidebarPanel(sliderInput("priceInput", "Price", 0, 100, c(25, 40), pre = "$"),

            wellPanel(
            checkboxInput("checkbox", "Filter by Type", FALSE),
            conditionalPanel(
              condition="checkbox==true",   
             selectInput("typeInput", "Product type",
                          choices = c("BEER", "REFRESHMENT", "SPIRITS", "WINE"),
                          selected = "WINE")
          )
        ),

             uiOutput("countryOutput")

),
mainPanel(
  tabsetPanel(
    tabPanel("Plot", plotOutput("coolplot")), 
    tabPanel("Summary", verbatimTextOutput("summary")), 
    tabPanel("Table", tableOutput("results"))
   )
  )
 )
)

server <- function(input, output, session) {
      output$countryOutput <- renderUI({
      selectInput("countryInput", "Country",
            sort(unique(bcl$Country)),
            selected = "CANADA")
  })  

     filtered <- reactive({ …
Run Code Online (Sandbox Code Playgroud)

r shiny

7
推荐指数
2
解决办法
9561
查看次数

标签 统计

r ×1

shiny ×1