chilipepper
chilipepper

Reputation: 81

Can I set the min and max values that a sliderInput will have when a Shiny app starts?

I have the following sliderInput:

slider <- sliderInput(
inputId = 'slider1',
label = 'Select value',
min = min(vector1),
max = max(vector1),
value = vector1,
step = (max(vector1)-min(vector1))/5
)

When the Shiny app starts, the min and max values of the slider are the one on top of the other, like this: https://i.sstatic.net/eLp9J.jpg

Can I set the min and max values that the slider will have when the app starts?

Upvotes: 1

Views: 737

Answers (1)

chilipepper
chilipepper

Reputation: 81

The value needs to be set to c(min(vector1), max(vector1)) instead of the whole vector1:

  sliderInput(
    inputId = 'slider1',
    label = 'Select value',
    min = min(vector1),
    max = max(vector1),
    value = c(min(vector1), max(vector1)),
    step = (max(vector1)-min(vector1))/5
    )

The assignment of the input to a variable has also been removed because, as latlio pointed out, it might cause namespacing issues.

Upvotes: 1

Related Questions