I used this example to get a dynamic UI for a shiny app. I'm now trying to source the sidebar panel. But when I do this, I get an ugly 'TRUE' in the sidebar. Anyone knows how to get rid of the TRUE without getting the sourceme.r text into the app. Maybe
source
is not the function is should use?
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"))
)