user3749759
user3749759

Reputation: 43

R shiny slider increments

Trying to setup a slider bar range from 0.5 - 999.5 with increments of 1 such that the range of values that it can take on is 0.5, 1.5, 2.5 ... 999.5 . My problem is that when I use the the slider from the code below, I get values including whole integer 1, 2, 3, 4...etc I have tried changing the steps to 0.5 but then I get, 1, 1.5, 2, 2.5 ...etc. Any ideas?

column(4,
         fileInput("pbs", label = ("PBS File input")),
         sliderInput("size", 
                     label = ("Size Range Selection"), 
                     min = 0.5, 
                     max = 999.5, 
                     value = c(0.5,999.5),
                     step = 1,
                    round = F

         )

Upvotes: 4

Views: 1338

Answers (1)

John Paul
John Paul

Reputation: 12684

So this is not the greatest, but it will work:

In your ui:

  sliderInput("size", 
                     label = ("Size Range Selection"), 
                     min = 0, 
                     max = 999, 
                     value = c(0,999),
                     step = 1,
                    round = F,
                    post=".5"
         )

This will show a slider that goes from 0 to 999, but it adds ".5" to the labels so it will look like 0.5 to 999.5.

Then, in your server, you will have to add .5 to each of the values from the slider before using the numbers.

Upvotes: 2

Related Questions