1

Shiny sliders don't seem to be working for me with dates, but they work fine with numbers. This works:

library(shiny)
ui <- fluidPage(
  sliderInput("range", "Range", min = 0, max = 10, value = c(2, 4))                                                           )                   
shinyApp(ui, function(...) {})

Screenshot of slider with numeric values

This doesn't:

 library(shiny)
ui <- fluidPage(
  sliderInput("range", "Range", min = as.Date("2021-01-01"), max = as.Date("2021-12-31"), value = c(as.Date("2021-02-02"), as.Date("2021-03-03")))
)                             
shinyApp(ui, function(...) {})

It just produces a blank box:

Screenshot of blank box

Any advice much appreciated.

Joseph
  • 13
  • 2
  • Maybe this answers your question: https://stackoverflow.com/questions/40908808/how-to-sliderinput-for-dates – ViviG Jan 17 '22 at 23:11

1 Answers1

1

Your code is working fine:

library(shiny)

ui <- fluidPage(sliderInput(
  inputId = "range",
  label = "Range",
  min = as.Date("2021-01-01"),
  max = as.Date("2021-12-31"),
  value = c(as.Date("2021-02-02"), as.Date("2021-03-03"))
))

server <- function(input, output, session) {}

shinyApp(ui, server)

result

ismirsehregal
  • 30,045
  • 5
  • 31
  • 78
  • 1
    Great - thanks - this is currently not working for me on debian bullseye, but there must be something wrong with my setup, I will investigate... – Joseph Jan 18 '22 at 16:32