简体   繁体   English

R闪亮滑块增量

[英]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 . 尝试设置滑块条的范围为0.5 - 999.5,增量为1,这样它可以采用的值范围是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. 我的问题是,当我使用下面代码中的滑块时,我得到的值包括整数1,2,3,4 ...等等我尝试将步骤更改为0.5,但后来我得到,1,1.5,2 ,2.5 ......等。 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

         )

So this is not the greatest, but it will work: 所以这不是最好的,但它会起作用:

In your ui : 在你的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. 这将显示一个从0到999的滑块,但它会在标签上添加“.5”,因此它看起来像0.5到999.5。

Then, in your server , you will have to add .5 to each of the values from the slider before using the numbers. 然后,在您的server ,您必须在使用数字之前为滑块中的每个值添加.5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM