Select 首次启动 shiny 应用时默认显示的特定 tabItem()

Select specific tabItem() to be displayed by default when shiny app is launched for first time

是否可以select shiny 应用首次启动时默认显示哪个选项卡项?我希望在应用程序启动时显示第二个 tabItem "Information"。我尝试了 selected=2 但没有成功。

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)

dbHeader <- dashboardHeaderPlus(
  titleWidth = "0px",
  tags$li(a(
    
    div(style="display: inline;margin-top:25px; padding: 0px 0px 0px 1250px;vertical-align:top; width: 150px;", actionButton("well", "Welcome", 
                                                                                                                             style=" background-color: #faf0e6; font:Monserrat Light; border-color: #faf0e6")),
    div(style="display: inline;margin-top:15px; padding: 0px 0px 0px 0px;vertical-align:top; width: 150px;", actionButton("info", "Information", 
                                                                                                                          style=" background-color: #faf0e6; border-color: #faf0e6"))
  ),
  class = "dropdown")
  
  
)

shinyApp(
  ui = dashboardPagePlus(
    header = dbHeader,
    sidebar = dashboardSidebar(width = "0px",
                               sidebarMenu(id = "sidebar", # id important for updateTabItems
                                           menuItem("Welcome", tabName = "well", icon = icon("house")),
                                           menuItem("Information", tabName = "info", icon = icon("table")),selected=2
                                           
                               )          ),
    body = dashboardBody(
      useShinyjs(),
      tags$script(HTML("$('body').addClass('fixed');")),
      
      tags$head(tags$style(".skin-blue .main-header .logo { padding: 0px;}")),
      
      
      tabItems(
        tabItem("well",
                paste("sdas")
                ),
        tabItem("info"
                
        )
      )
      
      
    )
    
  ),
  server<-shinyServer(function(input, output,session) { 
    hide(selector = "body > div > header > nav > a")
   
    
    
    observeEvent(input$well, {
      updateTabItems(session, "sidebar", "well")
    })
    observeEvent(input$info, {
      updateTabItems(session, "sidebar", "info")
    })
    
    
  }
  )
)

你可以直接在函数开头调用updateTabItems:

server <- shinyServer(function(input, output, session) {
  hide(selector = "body > div > header > nav > a")
  updateTabItems(session, "sidebar", "info")
  ...