【问题标题】:Bookmark does not work at Shiny Dashboard?书签在 Shiny Dashboard 中不起作用?
【发布时间】:2018-08-02 12:29:27
【问题描述】:

我可以在 Shiny 中使用 Bookmark,但在 Shiny Dashboard 中不能使用。

bookmarkButton() 给我一个新的网址。但是我输入它,它并没有得到新的结果。

library(shinydashboard)

ui <- 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)

【问题讨论】:

    标签: r shiny bookmarks shinydashboard


    【解决方案1】:

    您的 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)
    

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2021-03-30
      • 1970-01-01
      • 2016-07-21
      • 2014-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多