I am trying to use the bookmarked state in a URL for an R Shiny app (hosted on shinyapps.io) to choose what data to plot. The problem is that renderPlot doesn't plot. Whitespace is left where the plot should be. The javascript console error indicates a problem with string in the url?
"Error: util.addPathParams doesn't implement escaping"
This code replicates the problem. It seems to work OK locally.
#attempt to add bookmarking to rstudio lesson 1 and replicate bug
#https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/
library(shiny)
plotmsg =function(txt){return(plot(1:5,main=txt))} #this is new
ui <-function(request){ fluidPage( #UI wrapped in a function
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
textInput("w","name",value="a plot title"), #this is new
bookmarkButton() # This is new
),
mainPanel(
plotOutput("distPlot"),
plotOutput("plot"), # This is new
)
)
)
}
server <- function(input, output) {
output$plot <- renderPlot(plotmsg(input$w)) #this is new
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
shinyApp(ui = ui, server = server, enableBookmarking = "url") #this has added parameter