我有一个很好的动态生成的 shinyTree,它在闪亮仪表板的主体中显示得很漂亮。这太棒了。但是,我真正想要的是它位于侧边栏中,因此可以用来选择一个选项卡。但无论我尝试什么,我似乎都无法让它出现在侧边栏中。
下面不工作的代码:
library(shiny)
library(shinyTree)
library(shinydashboard)
library(shinydashboardPlus)
header <- dashboardHeader(title = "MWE")
body <- dashboardBody(
# works fine in the body
shinyTree("tree", stripes = TRUE, multiple = FALSE, animation = FALSE)
)
sidebar <- dashboardSidebar(
# doesn't work here
# shinyTree("tree", stripes = TRUE, multiple = FALSE, animation = FALSE)
sidebarMenu(
# doesn't work here
# shinyTree("tree", stripes = TRUE, multiple = FALSE, animation = FALSE)
menuItem("test"
# or here
# shinyTree("tree", stripes = TRUE, multiple = FALSE, animation = FALSE)
)
)
)
shinyUI(
dashboardPage(
header = header,
sidebar = sidebar,
body = body
)
)
shinyServer(function(input, output, session) {
# Simplified test tree
output$tree <- renderTree({
list(
root1 = "",
root2 = list(
SubListA = list(leaf1 = "", leaf2 = "", leaf3=""),
SubListB = list(leafA = "", leafB = "")
),
root3 = list(
SubListA = list(leaf1 = "", leaf2 = "", leaf3=""),
SubListB = list(leafA = "", leafB = "")
)
)
})
})
我觉得我错过了一些非常明显的东西,但我在谷歌和这里的搜索并没有带来任何东西。