Tingolfin Tingolfin - 1 year ago 204
R Question

R shiny: validate(need()) with dateRangeInput

I've read the help pages and shiny webpages on

10 times, googled all variations I could think of, but I simply cannot find what is wrong with my code.

The only thing I require is for my app to show a custom error instead of the (empty) plot when a user inputs a wrong date range = 2nd date earlier than the 1st.

output$plotTemp <- renderPlot({
validate(need(input$datums[1] < input$datums[2], "error: end date earlier than start"))
isolate({buttonFeedbackServer("button", { # if validate = ok, run functions
weerstation <- which(weerstations == input$weerstation)
temperatuur(input$datums, weerstation) # create plot

I get this error now: no applicable method for 'validate' applied to an object of class "NULL"

I bet it's gonna be something stupid, but I spent hours and hours on this without seeing it...

everything works perfect, so it's no mistake in other code.

My R, Rstudio and all packages have been updated last week.

Answer Source

Other packages, including jsonlite have a validate function. This error can occur when you accidentally are using a validate function from a different package. Try using shiny::validate instead to make sure you are using the correct validate.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download