You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The purpose of the example app for freezeReactiveValues is to demonstrate how to suppress error messages. However, it can still emit error messages in some cases.
This is a slightly modified version of the example app (I added some message() calls):
ui<- fluidPage(
selectInput("data", "Data Set", c("mtcars", "pressure")),
checkboxGroupInput("cols", "Columns (select 2)", character(0)),
plotOutput("plot")
)
server<-function(input, output, session) {
observe({
message("observe: ", input$data)
data<- get(input$data)
# Sets a flag on input$cols to essentially do req(FALSE) if input$cols# is accessed. Without this, an error will momentarily show whenever a# new data set is selected.
freezeReactiveValue(input, "cols")
updateCheckboxGroupInput(session, "cols", choices= names(data))
})
output$plot<- renderPlot({
message("renderPlot: ", input$data)
# When a new data set is selected, input$cols will have been invalidated# above, and this will essentially do the same as req(FALSE), causing# this observer to stop and raise a silent exception.cols<-input$colsdata<- get(input$data)
if (length(cols) ==2) {
plot(data[[ cols[1] ]], data[[ cols[2] ]])
}
})
}
shinyApp(ui, server)
If you check two of the columns so that a plot shows up, and then select the other data set, sometimes a red error message shows up briefly, and this appears in the console:
renderPlot: mtcars
renderPlot: mtcars
renderPlot: mtcars
renderPlot: pressure
Warning in min(x) : no non-missing arguments to min; returning Inf
Warning in max(x) : no non-missing arguments to max; returning -Inf
Warning in min(x) : no non-missing arguments to min; returning Inf
Warning in max(x) : no non-missing arguments to max; returning -Inf
Warning: Error in plot.window: need finite 'xlim' values
[No stack trace available]
observe: pressure
The error occurs because the renderPlot is executing before the observer when the data set is changed. I can't get this to happen consistently, though. It happens the first time when I run the app in a new R session, but not after that. This is with Shiny 1.3.2.
However, with the fastmap PR (#2429), I can get the error message every time, not just the first time.
The text was updated successfully, but these errors were encountered:
This is real, and addressed by #3055. Specifically, calling freezeReactiveValue later in the same flush cycle as an output that already used that input, is not ideal, but we also don't want the error to make it to the client. We should encourage people to set the freezeReactiveValue's parent observer to a higher priority, but suppress the error from the UI in either case.
The purpose of the example app for
freezeReactiveValues
is to demonstrate how to suppress error messages. However, it can still emit error messages in some cases.This is a slightly modified version of the example app (I added some
message()
calls):If you check two of the columns so that a plot shows up, and then select the other data set, sometimes a red error message shows up briefly, and this appears in the console:
The error occurs because the
renderPlot
is executing before the observer when the data set is changed. I can't get this to happen consistently, though. It happens the first time when I run the app in a new R session, but not after that. This is with Shiny 1.3.2.However, with the fastmap PR (#2429), I can get the error message every time, not just the first time.
The text was updated successfully, but these errors were encountered: