I am able to use Bookmark at Shiny ,But does not work at Shiny Dashboard .
bookmarkButton()
give me a new url. But i enter it ,it dose not get me the new result.
#############################################
## app.R ##
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)
Problem solved. by marking ui as a function
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('bookmark1')
)
)
)
)
}
2 Likes
@Tony_Duan I am glad you figured out your problem. Would you mind marking your post containing your solution as "solution". If you click the ...
at the bottom of the post you should see a box with a check in it. If you click that then it will be marked as correct.
In the future, when posting code, please wrap your code with three backticks ```
on the lines above and below your code so that it is formatted correctly. Thanks!
Hi Tony, thanks for the solution!
I wonder why it work after changing ui to a function?
Also note that, the "request" argument in ui() is redundant, and the bookmark works fine after removing "request".
ui <- function() {
...
}
1 Like