我是 Shiny 和 Shinydashboard 的新手。请考虑以下代码片段(大量代码的一小部分):
dbsidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Rank List", icon = icon("th"), tabName = "Widgets1", badgeColor = "green"),
menuItem("Build Your", icon = icon("th"), tabName = "Widgets2", badgeColor = "green"),
menuItem("Groups", icon = icon("th"), tabName = "Widgets3", badgeColor = "green")
)
)
dbBody <- dashboardBody(
tabItems(
tabItem(tabName = "dashboard",
fluidRow(
#Pie Charts
splitLayout(
#cellWidths = c("50%", "50%"),
style = "border: 1px solid silver;",
cellWidths = 450,
cellArgs = list(style = "padding: 6px"),
plotlyOutput("Piechart1", width = "400px", height = "200px"),
plotlyOutput("Piechart2", width = "400px", height = "200px"),
plotlyOutput("Piechart3", width = "400px", height = "200px")
)
)
),
tabItem(tabName = "Widgets1",
#Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("TCScore","TCScore:",min = 0, max = 100, value = c(0,100))
),
# Show a plot of the generated distribution
mainPanel(
tabPanel("Heading", plotlyOutput("tbTable"))
)
),
downloadButton('downloadData', 'Download')
),
tabItem(tabName = "Widgets2", "XX"
# #Data Table
# sidebarLayout(
# sidebarPanel(
# sliderInput("TCCScore","TCCScore:",min = 0, max = 100, value = c(0,100)),
# ),
#
# # Show a plot of the generated distribution
# mainPanel(
# tabPanel("Heading", dataTableOutput("tbTable1"))
# )
#
# ),
# downloadButton('downloadData', 'Download')
),
tabItem(tabName = "Widgets3", "third"
)
)
)
在dashboardSidebar 上,我添加了4 个选项卡-dashboard、Widget1、Widget2、Widget3。最初对于这些选项卡中的每一个,我使用简单的文本来呈现 UI dashboardBody,并且我得到了正确的显示。我开始填写这些部分中的每一个 - “仪表板”、“Widget1”,并且显示对我来说正常工作。不幸的是,对于“Widget2 - 当我删除“XX”并取消注释上面显示的代码时,UI 完全扭曲了。看起来dashboardBody 中的主要 UI 元素没有被渲染?谁能告诉我我做错了什么? 请帮忙。很抱歉我没有发布完整的工作代码,但它太长了,因此我只需要发布一个小代码片段。
提前致谢!欢呼!