从服务器调用仪表板页面

时间:2018-10-16 02:53:55

标签: r shiny

我正在尝试从Shiny的服务器中的函数调用dashboardPage。它不显示dahsboard页面,而是显示空白页面。如何将其重定向到我的dashboardPage。目前,重定向后向我显示空白页。 以下是代码:

## app.R ##
library(shinydashboard)
library(shiny)
library(shinythemes)
library(DT)
ui1 <- function(){}

ui2 <- dashboardPage(){}

ui = (uiOutput("page"))

server <- function(input, output, session) {
if (USER$Logged == TRUE) 
    {
      output$page <- renderUI({
         ui2() 
      ###Here is the problem. It is not redirecting to ui2 which is
      ###a dashboardPage.
      })
    }
}

1 个答案:

答案 0 :(得分:0)

您没有正确实现dashboardPage功能。下面的代码将为您提供一个使用它的思路。

library(shinydashboard)
library(shiny)
library(shinythemes)
library(DT)

header <- dashboardHeader(
  title = "dynamicDates",
  tags$li(class = "dropdown", tags$a(HTML(paste(uiOutput("Refresh1"))))))
body <- dashboardBody("this is body function", 
                      uiOutput("page"))
sidebar <- dashboardSidebar("this is side bar")
#we must pass header,body and sidebar parameters in dashboardPage funtion, which you have missed to specify. 
ui <- dashboardPage(header, sidebar, body, title = "example") 

server <- function(input, output, session) {
  output$Refresh1 <- renderText({
    toString(format(Sys.Date(), format = "%A  %d %b %Y"))
  })
  output$page <- renderUI("shiny dashboard")
}

shinyApp(ui, server)