DT::renderDT 当有多个 tabPanel 时不工作

DT::renderDT not working when more than one tabPanel

此代码无法在 tabPanel“table”中生成 table,但是,当我评论其中一个 tabPanel(例如“概述” ) 它工作正常。知道为什么会这样吗?

library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(DT)

ui <- 
  navbarPage("App Title",
             
             tabPanel("Overview",
                      sidebarLayout(position = "right", fluid = T,
                                    sidebarPanel(width = 3,
                                                 
                                                 radioButtons("percentage_select", "Percentage of:",
                                                              c("All Publications" = "p",
                                                                "All SDG Publications" = "l")
                                                 ),
                                                 
                                                 checkboxGroupInput("sdg_select", "SDG:",
                                                                    choices = c(1, 2),
                                                                    selected = c(1, 2),
                                                                    inline = T
                                                 ),
                                                 
                                                 sliderInput("year_range", "Years:",
                                                             min = 2011,
                                                             max = 2020,
                                                             value = range(2011, 2020),
                                                             round = T,
                                                             step = 1,
                                                             ticks = T
                                                 ),
                                                 
                                                 actionButton('reset_filters', 'Reset Filters',
                                                              icon = icon("sync")
                                                 )
                                    ),
                                    
                                    mainPanel(
                                      plotOutput("plot")
                                    )
                      )
             ),
             
             tabPanel("Cumulative",
                      sidebarLayout(position = "right", fluid = T,
                                    sidebarPanel(width = 3,
                                                 
                                                 radioButtons("percentage_select", "Indicator:",
                                                              c("Percentage" = "p",
                                                                "Absolute" = "l")
                                                 ),
                                                 
                                                 checkboxGroupInput("baseline_select", "Show average:",
                                                                    choices = c("World", "Univ. "),
                                                                    selected = c("World", "Univ. "),
                                                                    inline = F
                                                 ),
                                                 
                                                 checkboxGroupInput("sdg_select", "SDG:",
                                                                    choices = c(1, 2),
                                                                    selected = c(1, 2),
                                                                    inline = T
                                                 ),
                                                 
                                                 sliderInput("year_range", "Years:",
                                                             min = 2011,
                                                             max = 2020,
                                                             value = range(2011, 2020),
                                                             round = T,
                                                             step = 1,
                                                             ticks = T
                                                 ),
                                                 
                                                 actionButton('reset_filters', 'Reset Filters',
                                                              icon = icon("sync")
                                                 )
                                    ),
                                    
                                    mainPanel(
                                      plotOutput("plot")
                                    )
                      )
             ),
             
             tabPanel("table",
                      fluidPage(DTOutput('tbl'))
             ))

server <- function(input, output){
  
  output$tbl = renderDT(
    iris, options = list(lengthChange = FALSE), server = F
  )
  
}

shinyApp(ui, server)

plotOutput("plot") 被重复(查看浏览器控制台):

library(DT)
library(shiny)
library(shinyWidgets)
library(shinydashboard)
library(datasets)

ui <- navbarPage(
  "App Title",
  # header = css,
  tabPanel(
    "Overview",
    sidebarLayout(
      position = "right",
      fluid = TRUE,
      sidebarPanel = sidebarPanel(
        width = 3,
        radioButtons(
          "percentage_select",
          "Percentage of:",
          c(
            "All Publications" = "p",
            "All SDG Publications" = "l"
          )
        ),
        checkboxGroupInput(
          "sdg_select",
          "SDG:",
          choices = c(1, 2),
          selected = c(1, 2),
          inline = T
        ),
        sliderInput(
          "year_range",
          "Years:",
          min = 2011,
          max = 2020,
          value = range(2011, 2020),
          round = TRUE,
          step = 1,
          ticks = TRUE
        ),
        actionButton('reset_filters', 'Reset Filters',
                     icon = icon("sync"))
      ),
      mainPanel = mainPanel(plotOutput("plot1"))
    )
  ),
  tabPanel(
    "Cumulative",
    sidebarLayout(
      position = "right",
      fluid = TRUE,
      sidebarPanel = sidebarPanel(
        width = 3,
        radioButtons(
          "percentage_select",
          "Indicator:",
          c("Percentage" = "p",
            "Absolute" = "l")
        ),
        checkboxGroupInput(
          "baseline_select",
          "Show average:",
          choices = c("World", "Univ. "),
          selected = c("World", "Univ. "),
          inline = FALSE
        ),
        checkboxGroupInput(
          "sdg_select",
          "SDG:",
          choices = c(1, 2),
          selected = c(1, 2),
          inline = TRUE
        ),
        sliderInput(
          "year_range",
          "Years:",
          min = 2011,
          max = 2020,
          value = range(2011, 2020),
          round = TRUE,
          step = 1,
          ticks = TRUE
        ),
        actionButton('reset_filters', 'Reset Filters',
                     icon = icon("sync"))
      ),
      mainPanel = mainPanel(plotOutput("plot2"))
    )
  ),
  tabPanel("Table", fluidPage(DTOutput('tbl')))
)

server <- function(input, output, session) {
  output$tbl <- renderDT({
    iris
  },
  options = list(lengthChange = FALSE),
  server = FALSE)
  
}

shinyApp(ui, server)