I have a simple shiny app which I would like to show a warning if user input is bigger than a threshold.
library(shiny)
library(shinyalert)
ui <- fluidPage(
numericInput("obs", "Observations:", 1),
verbatimTextOutput("value")
)
server <- function(input, output) {
observeEvent(input$obs,{
if(!is.na(input$obs) && input$obs >10){
shinyalert("warning!", "input too big", type = "warning")
}
})
output$value <- renderText({ input$obs })
}
shinyApp(ui, server)
if user is not quick enough to provide input, let say for the input$obs = 110
we have 1 second delay between putting the second and third value the popups warning will appear !
How should I fix this ?
You can use
showNotification()
from shiny itself:Or
{shinytoastr}
:Or
{spsComps}
as @lz100 mentioned. The choice is yours.