我正在尝试从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.
})
}
}
答案 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)