Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将选项卡项和子项与shinydashboard中的主体连接_R_Shiny_Shinydashboard - Fatal编程技术网

将选项卡项和子项与shinydashboard中的主体连接

将选项卡项和子项与shinydashboard中的主体连接,r,shiny,shinydashboard,R,Shiny,Shinydashboard,我有一个shinydashboard,上面有tabItems和sub-items。每个选项在选中时都应该在主体中显示相应的项目,但这不起作用 #ui.r library(shiny) library(shinydashboard) library(shinydashboardPlus) ui <- dashboardPagePlus( dashboardHeaderPlus(title = "AA Tester"), dashboardSidebar( dashboardS

我有一个shinydashboard,上面有tabItems和sub-items。每个选项在选中时都应该在主体中显示相应的项目,但这不起作用

#ui.r
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
ui <- dashboardPagePlus(
  dashboardHeaderPlus(title = "AA Tester"),
  dashboardSidebar(
    dashboardSidebar(
      sidebarMenu(id = 'sidebarmenu',
                  menuItem('Introduction', tabName = 'intro', icon = icon('dashboard')),
                  menuItem('Explore Funds', tabName = 'expf',
                           icon = icon('th'),
                           menuItem('Choose Strategy',
                                    tabName = 'retAA',
                                    icon = icon('line-chart'),
                                    selectInput("str", "Strategies:", choices=c("Strategy 1",
                                                                                     "Strategy 2",
                                                                                     "Strategy 3",
                                                                                     "Strategy 4",
                                                                                     "Strategy 5",
                                                                                     "Strategy 6",
                                                                                     "Strategy 7",
                                                                                     "Strategy 8"),multiple = T,selected = "Strategy 1"))
                  )))


  ),
  dashboardBody(
    tabItems(
      # First tab content
      tabItem(tabName = "intro",
              fluidRow(
                h2("Intro tab content")
              )
      ),

      # Second tab content
      tabItem(tabName = "retAA",
              h2("Exp tab content")
      )
    )
  )
)
#server.r
server <- function(input, output) { }
#ui.r
图书馆(闪亮)
图书馆(shinydashboard)
图书馆(shinydashboardPlus)

ui您需要进行以下几项更改:

  • 对于选项卡
    retAA
  • retAA
    selectInput
    应为同级
  • 添加用于显示策略的UI
  • 您需要添加服务器代码,以监听
    selectInput
  • 
    #用户界面
    图书馆(闪亮)
    图书馆(shinydashboard)
    图书馆(shinydashboardPlus)
    
    这是一个很好的方法。一个小问题是,只要我按下一个新的选项卡项(探索基金),而不必按下“选择策略”,我就会显示相应的面板。