【问题标题】:tabItem doenst display R shinytabItem 不显示 R 闪亮
【发布时间】:2018-12-21 22:36:52
【问题描述】:

我在一个闪亮的应用程序中有多个 tabItem。当我注释掉第二个 tabItem 时,第一个 tabItem 中的内容会正确显示,但是当我拥有两个 tabItem 时,我只能看到第二个选项卡的内容。

下面是 UI.r 的代码

library(shiny)
library(shinydashboard)
library(plotly)


dashboardPage(
  dashboardHeader(title = "Loyalty Monthly Scorecard", titleWidth = 300),
  ## Sidebar content
  dashboardSidebar(sidebarMenu(
    menuItem("ATC Topline",tabName = "atc_topline"),
    menuItem("Guidelines & KPI", tabName = "guidelines")
  )),
  ## Body content
  dashboardBody(tabItems(
    tabItem(tabName = "atc_topline",
            fluidRow(
              box(
                title = "ATC Topline Plot",
                width = 12,
                solidHeader = TRUE,
                status = "primary",
                plotlyOutput("plot"),
                collapsible = T
              )
            )),
    # # Second tab content
    tabItem(tabName = "guidelines",
            fluidRow(
              includeHTML("include.html")
            ))
  ))
)

【问题讨论】:

  • include.html 不可用。
  • 我有它在文件结构中,它显示正确。当我有 tabName="guidelines" 时,情节不显示

标签: r shiny shinydashboard


【解决方案1】:

虽然没有给出足够的问题陈述,但尝试复制相同的内容并没有发现问题。

这是我的代码:

ui.R

library(shiny)
library(shinydashboard)
library(plotly)


dashboardPage(
  dashboardHeader(title = "Loyalty Monthly Scorecard", titleWidth = 300),
  ## Sidebar content
  dashboardSidebar(sidebarMenu(
    menuItem("ATC Topline",tabName = "atc_topline"),
    menuItem("Guidelines & KPI", tabName = "guidelines")
  )),
  ## Body content
  dashboardBody(tabItems(
    tabItem(tabName = "atc_topline",
            fluidRow(
              box(
                title = "ATC Topline Plot",
                width = 12,
                solidHeader = TRUE,
                status = "primary",
                plotlyOutput("plot"),
                collapsible = T
              )
            )),
    # # Second tab content
    tabItem(tabName = "guidelines",
            fluidRow(
              includeHTML("test.html")
            ))
  ))
)


Server.R

shinyServer(function(input, output) {

output$plot<-renderPlotly({
  ggplotly(
    ggplot(data = mtcars, aes(x = disp, y = cyl)) + 
      geom_smooth(method = lm, formula = y ~ x) + 
      geom_point()) 
})


})

html文件是一个基本的html文件:

<html>
<head>
header
</head>
<body>
Body
</body>

</html>

请尝试一下。同时清除您的问题陈述。

【讨论】:

    猜你喜欢
    • 2019-05-11
    • 2014-05-13
    • 2021-09-02
    • 2018-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-16
    • 1970-01-01
    相关资源
    最近更新 更多