我使用this example为闪亮的应用获取动态用户界面。我现在正试图寻找侧边栏面板。但是当我这样做时,我会得到一个丑陋的' TRUE'在侧边栏。 任何人都知道如何在不将sourceme.r文本放入应用程序的情况下摆脱TRUE。也许source
不是应该使用的功能?
require(shiny)
require(shinydashboard)
mainbody <- div(tabItems(
tabItem(tabName = "t_item1", class = "active", box(title = "Item 1 information")),
tabItem(tabName = "t_item2", box(title = "Item 2 information")),
tabItem(tabName = "t_item3", box(title = "Item 3 information"))
)
)
header <- dashboardHeader(title = "dashboard header")
sidebar <- dashboardSidebar(uiOutput("sidebarpanel"))
body <- dashboardBody(uiOutput("body"))
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output, session) {
output$sidebarpanel <- renderUI({
# if (USER$Logged == TRUE) {
# div(
source('~/sourceme.r')
# sidebarMenu(
# menuItem("Item 1", tabName = "t_item1", icon = icon("line-chart")),
# menuItem("Item 2", tabName = "t_item2", icon = icon("users")),
# menuItem("item 3", tabName = "t_item3", icon = icon("dollar"))
# )
# )
})
output$body <- renderUI({
mainbody
})
}
shinyApp(ui, server)
sourceme.r:
sidebarMenu(
menuItem("Item 1", tabName = "t_item1", icon = icon("line-chart"), selected = TRUE),
menuItem("Item 2", tabName = "t_item2", icon = icon("users")),
menuItem("item 3", tabName = "t_item3", icon = icon("dollar"))
)
答案 0 :(得分:3)
制作返回sourceme.r
的{{1}} 函数的内容。然后将sidebarMenu
调用放在source
函数之外,并调用server
函数中的新函数以返回server
。