我正在尝试使用R Shiny将状态标记为URL。该应用程序在首次使用时可以正常运行,并保持URL正常,但是当我使用该URL或只是刷新浏览器时,该应用程序未显示应该显示的图。
javascript控制台显示: “错误:util.addPathParams没有实现转义”
它还会引发此错误: 未处理的承诺拒绝:TypeError:a.LegacyGlobal.LP_explicit_ignored不是函数。 (在'a.LegacyGlobal.LP_explicit_ignored(document,e)'中,'a.LegacyGlobal.LP_explicit_ignored'未定义)
似乎不喜欢url中的文本。
我发现我可以通过在rstudio网站上的第1课中学习“你好,闪亮”来复制自己犯的任何错误。我用注释标记了编辑的行。 https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/
这是shinyapps.io上的以下代码: https://jackprior.shinyapps.io/shinypractice/
#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
答案 0 :(得分:0)
这里的问题是使用“ w”作为输入参数。 Shinyapps.io将&w编码为无法评估的内容,并在永久评估中挂起了反应式。输入使用其他名称进行修复。除非用户不知道不使用“ w”,否则这似乎是shinyapps.io错误。我只是用它来最小化URL的长度。