您的UI应该是一个函数,如您得到的错误所示,请参见
the documentation
工作示例:
library(shinydashboard)
ui <- function(request) {
dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(),
dashboardBody(
# Boxes need to be put in a row (or column)
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50),
bookmarkButton()
)
)
)
)
}
server <- function(input, output,session) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
enableBookmarking(store = "url")
shinyApp(ui, server)
希望这有帮助!