【问题标题】:Shinydashboars tabItems not working properlyShinydashboars tabItems 无法正常工作
【发布时间】:2015-08-05 22:42:27
【问题描述】:

我正在测试 shinydashboard 包,但我无法弄清楚在特定情况下发生了什么。我的仪表板有 4 个 tabItems(抱歉是荷兰语):

  • 程序
  • Deelnemers
  • Notulen
  • 上色

仪表板正常加载,但tabItem 4(“Overige”)的内容显示在“Notulen”的内容下方。

App代码如下:

library(shiny)
library(shinydashboard)
library(markdown)
library(DT)


# Simple header -----------------------------------------------------------

header <- dashboardHeader(title="Economencongres")

# Sidebar --------------------------------------------------------------

sidebar <- ## Sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem(
        "Programma 2015",
        tabName = "Programma",
        icon = icon("info-circle")
      ),
      menuItem(
        "Deelnemers",
        tabName = "Deelnemers",
        icon = icon("users")
      ),
      menuItem(
        "Notulen",
        tabName = "Notulen",
        icon = icon("file-text")
      ),
      menuItem(
        "Presentaties",
        tabName = "Presentaties",
        icon = icon("file-movie-o")
      )
    )
  )

# Compose dashboard body --------------------------------------------------

body <- dashboardBody(
  tabItems(
    # First tab content
    # Boxes need to be put in a row (or column)
    tabItem(
      tabName = "Programma",
      fluidRow(
        tabBox(
          width = 12,
          title = "",
          id = "tabset1", height = "250px",
          tabPanel(
            "Agenda",
            h2(""),
            width = 12,
            h2("Agenda d.d. 25-03-2015"),
            includeHTML("Agenda.html")
          ),
          tabPanel(
            "Presentatie ABN AMRO",
            h2("Danny van Brummelen"),
            tags$iframe(
            width="800",
            height="600",
            seamless="seamless",
            src="http://www.allmoocs.nl/wordpress/wp-content/uploads/2015/05/ABN.pdf"
            )
          ),
          tabPanel(
            "Presentatie HAN BKMER",
            h2("Witek ten Hove"),
            h4("Klik op de presentatie en navigeer met de pijlen op het toetsenbord"),
            tags$iframe(
            width="1000",
            height="800",
            seamless="seamless",
            src="http://witusj.github.io/Economencongres/economen25032015.html"
            )
          )
        ) # End of tabBox
      ) # End of fluidRow
    ), # End of tabItem

    # Second tab content
    # Boxes need to be put in a row (or column)
    tabItem(
      tabName = "Deelnemers",
      fluidRow(
        tabBox(
          width = 12,
          title = "",
          id = "tabset2", height = "250px",
          tabPanel("Kaart",
                   h2(""),
                   tags$iframe(
                     width="800",
                     height="600",
                     seamless="seamless",
                     src="http://www.allmoocs.nl/wordpress/wp-content/uploads/2015/05/map.html"
                   )
          ),
          tabPanel("Lijst",
                   DT::dataTableOutput('deeln')
          )
        ) # End of tabBox
      ) # End of fluidRow,
    ), # End of tabItem

    # Third tab content
    # Boxes need to be put in a row (or column)
    tabItem(
      tabName = "Notulen",
      fluidRow(
        box(
          h2(""),
          width = 12,
          includeMarkdown("txt10.md")
        ),
        box(
          h2(""),
          width = 12,
          includeMarkdown("txt11.md")
        ),
        box(
          h2(""),
          width = 12,
          includeMarkdown("txt12.md")
        )
      ) # End of fluidRow
    ), # End of tabItem

    # Fourth tab content
    # Boxes need to be put in a row (or column)
    tabItem(
      tabName = "Presentaties",
      fluidRow(
        box(
          h2("Hello")
        )
      ) # End of fluidRow
    ) # End of tabItem
  ) ## End tabItems
) ## End dashboardBody




# Setup Shiny app UI components -------------------------------------------

ui <- dashboardPage(header, sidebar, body, skin = "purple")

# Setup Shiny app back-end components -------------------------------------

server <- function(input, output) {

  source('map.R')
  output$deeln <- DT::renderDataTable({
    DT::datatable(ec[,c(2:8)])

 })
}


# Render Shiny app --------------------------------------------------------

shinyApp(ui, server)

一定是我的无知,但它让我发疯了!

更新:我清理了一下代码,但问题仍然存在。

【问题讨论】:

    标签: r shiny menuitem dashboard tabitem


    【解决方案1】:

    我解决了!该问题似乎是由 .md 文件引起的。我不知道为什么,但它们阻止了 tabItem 的关闭。奇怪的是,它最初似乎可以在 RStudio 环境中工作,而现在却不行。然而,在我的AWS Shiny Server 上部署后,一切看起来都很好。这里发生了奇怪的事情!

    library(shiny)
    library(shinydashboard)
    library(markdown)
    library(DT)
    
    
    # Simple header -----------------------------------------------------------
    
    header <- dashboardHeader(title="Economencongres")
    
    # Sidebar --------------------------------------------------------------
    
    sidebar <- ## Sidebar content
      dashboardSidebar(
        sidebarMenu(
          menuItem(
            "Programma 2015",
            tabName = "Programma",
            icon = icon("info-circle")
          ),
          menuItem(
            "Deelnemers",
            tabName = "Deelnemers",
            icon = icon("users")
          ),
          menuItem(
            "Notulen",
            tabName = "Notulen",
            icon = icon("file-text")
          ),
          menuItem(
            "Presentaties",
            tabName = "Presentaties",
            icon = icon("file-movie-o")
          )
        )
      )
    
    # Compose dashboard body --------------------------------------------------
    
    body <- dashboardBody(
      tabItems(
    
        # First tab content
        # Boxes need to be put in a row (or column)
        tabItem(
          tabName = "Programma",
          fluidRow(
            box(
              width = 12,
              h2("Agenda d.d. 25-03-2015"),
              includeHTML("Agenda.html")
            ) 
          ) # End of fluidRow
        ), # End of tabItem
    
        # Second tab content
        # Boxes need to be put in a row (or column)
        tabItem(
          tabName = "Deelnemers",
          fluidRow(
            tabBox(
              width = 12,
              title = "",
              id = "tabset2", height = "250px",
              tabPanel("Kaart",
                       h2(""),
                       tags$iframe(
                         width="800",
                         height="600",
                         seamless="seamless",
                         src="http://www.allmoocs.nl/wordpress/wp-content/uploads/2015/05/map.html"
                       )
              ),
              tabPanel("Lijst",
                       DT::dataTableOutput('deeln')
              )
            ) # End of tabBox
          ) # End of fluidRow,
        ), # End of tabItem
    
        # Third tab content
        # Boxes need to be put in a row (or column)
        tabItem(
          tabName = "Notulen",
          fluidRow(
            box(
              h2(""),
              width = 12,
              includeMarkdown("txt10.md")
            ),
            box(
              h2(""),
              width = 12,
              includeMarkdown("txt11.md")
            ),
            box(
              h2(""),
              width = 12,
              includeMarkdown("txt12.md")
            )
          ) # End of fluidRow
        ), # End of tabItem
    
        # Fourth tab content
        # Boxes need to be put in a row (or column)
        tabItem(
          tabName = "Presentaties",
          fluidRow(
            tabBox(
              width = 12,
              title = "",
              id = "tabset1",
              height = "250px",
              tabPanel(
                  "Presentatie ABN AMRO",
                  h2("Danny van Brummelen"),
                  box(
                  tags$iframe(
                    width="800",
                    height="600",
                    seamless="seamless",
                    src="http://www.allmoocs.nl/wordpress/wp-content/uploads/2015/05/ABN.pdf"
                  )
                )
              ),
              tabPanel(
                  "Presentatie HAN BKMER",
                  h2("Witek ten Hove"),
                  h4("Klik op de presentatie en navigeer met de pijlen op het toetsenbord"),
                  box(
                  tags$iframe(
                    width="1000",
                    height="800",
                    seamless="seamless",
                    src="http://witusj.github.io/Economencongres/economen25032015.html"
                  )
                )
              )
            ) # End of tabBox
          ) # End of fluidRow
        ) # End of tabItem
      ) ## End tabItems
    ) ## End dashboardBody
    
    
    
    
    # Setup Shiny app UI components -------------------------------------------
    
    ui <- dashboardPage(header, sidebar, body, skin = "purple")
    
    # Setup Shiny app back-end components -------------------------------------
    
    server <- function(input, output) {
    
      source('map.R')
      output$deeln <- DT::renderDataTable({
        DT::datatable(ec[,c(2:8)])
    
      })
    }
    
    
    # Render Shiny app --------------------------------------------------------
    
    shinyApp(ui, server
    

    )

    【讨论】:

      猜你喜欢
      • 2016-12-01
      • 1970-01-01
      • 2016-09-01
      • 2012-07-11
      • 2018-04-08
      • 2017-04-20
      • 2018-10-02
      • 2016-09-04
      • 2010-10-06
      相关资源
      最近更新 更多