【问题标题】:Filters in sidebar menu not showing in R shiny侧边栏菜单中的过滤器未在 R 中显示
【发布时间】:2021-09-05 09:29:18
【问题描述】:

我正在尝试在侧边栏菜单中创建过滤器。代码如下

data:
col1
a
b
c

ui.R

dashboardPage(
  dashboardHeader(title = "Dashboard",titleWidth = 2000,disable = F),
  dashboardSidebar(disable = T,
                   
                   sidebarMenu(
                     
                     menuItem(
                              # Input directly under menuItem
                              selectInput("input1", "Select input",
                                          choices = c(unique(data$col1))
                                          )
                     ) 
                              )
  ),
  dashboardBody()
)

服务器.R

shinyServer(function(input, output,session){
  print('shiny')
  
  do something
  
})

使用上面的代码我也看不到侧边栏菜单。我哪里出错了?

【问题讨论】:

  • 在服务器中,您没有进行任何过滤,即subset(data, col1 %in% input$input1)
  • 我想查看模板,即是否在侧边栏菜单中创建了过滤器。使用这些过滤器我必须绘制。此处未添加该代码。
  • 您是从模板示例中创建的吗
  • 我尝试了该链接中的一个示例。它对我有用

标签: r filter shiny


【解决方案1】:

代码中有一个disable = T,即TRUE,它禁用。改成FALSE

shinyApp(
  ui = dashboardPage(
    dashboardHeader(title = "Dashboard",titleWidth = 2000,disable = FALSE),
    dashboardSidebar(disable = FALSE,
                     
                     sidebarMenu(
                       
                       menuItem(
                         # Input directly under menuItem
                         selectInput("input1", "Select input",
                                     choices = c(unique(data$col1))
                         )
                       ) 
                     )
    ),
    dashboardBody()
  ),
  server = function(input, output) {
    
    print("shiny")
    })
    
  }

【讨论】:

  • 感谢您花时间回答这个问题。它现在正在工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-18
相关资源
最近更新 更多