我在R闪亮的仪表板上有一个表,但是当我在该表下添加菜单子项时,屏幕上不再呈现任何内容
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
menuItem("Table" , tabname = "my_table", icon = icon("table"),
menuSubItem("sub menu",
tabName = "subMenu")),
menuItem("Next Widget", tabName = "Other"))),
dashboardBody(
tabItems(
tabItem(tabName = "my_table",
fluidRow(DT::dataTableOutput("example_table")
)),
tabItem(tabName = "Other",
h2("Other tab")
)
)))
答案 0 :(得分:3)
您的方法正确。请确保在服务器中使用DT::
,因为renderDataTable
(来自软件包shiny
)不能与DT::dataTableOutput
(来自软件包DT
)配合使用:>
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
menuItem("Table" , tabname = "my_table", icon = icon("table"),
menuSubItem("sub menu",
tabName = "subMenu")),
menuItem("Next Widget", tabName = "Other"))),
dashboardBody(
tabItems(
tabItem(tabName = "subMenu", #my_table",
fluidRow(DT::dataTableOutput("example_table")
)),
tabItem(tabName = "Other",
h2("Other tab")
)
)))
server <- function(input, output) {
output$example_table <- DT::renderDataTable(head(mtcars))
}
shinyApp(ui, server)