2

I would like to create a sliderInput for a Shiny app which accepts a year as input, with all possible integer values from a variable time in the past (e.g. 1866) to the current year. Most users will only be interested in recent years, for for better UX I would like uneven spacing on the slider.

Note that answers like this one exist for using a slider with a nonlinear scale - this is not what I am looking for. The acceptable values for the slider should still be any integer in the range (and nothing else), but I would like the values to be spaced differently, like in the cartoon example below (ticks displayed every 5 years pre-1980 for visibility).

A schematic depiction of uneven spacing

Scott Gigante
  • 1,450
  • 1
  • 17
  • 29
  • Look into this answer https://stackoverflow.com/questions/30502870/shiny-slider-on-logarithmic-scale maybe it can help you – Bertil Baron Nov 16 '17 at 19:47
  • @BertilNestorius I included a link to that very question in my question... It's not what I'm looking for. "Note that answers like this one exist for using a slider with a nonlinear scale - this is not what I am looking for. The acceptable values for the slider should still be any integer in the range (and nothing else), but I would like the values to be spaced differently." – Scott Gigante Nov 16 '17 at 21:11

1 Answers1

0

You can accomplish this by using shinyWidgets::sliderTextInput, which allows you to supply a character vector of choices.

John J.
  • 1,450
  • 1
  • 13
  • 28
  • Unfortunately as far as I can see if I want any integer in the range to be an option, then this would still be a linear scale. You are right though that this may be a good compromise - by restricting the number of available choices I could have a nonlinear scale. – Scott Gigante May 18 '19 at 16:12