采购动态用户界面会提供“真实”的信息。在闪亮

时间:2016-11-18 11:38:15

标签: r shiny shinydashboard

我使用this example为闪亮的应用获取动态用户界面。我现在正试图寻找侧边栏面板。但是当我这样做时,我会得到一个丑陋的' TRUE'在侧边栏。 enter image description here任何人都知道如何在不将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"))
)

1 个答案:

答案 0 :(得分:3)

制作返回sourceme.r的{​​{1}} 函数的内容。然后将sidebarMenu调用放在source函数之外,并调用server函数中的新函数以返回server