我的 R Shiny 滑块输入有问题。正如您在 in this picture 中看到的那样,“圆形功能”不起作用。我做错什么了吗 ?

  sliderInput("Er", "Choose expected return (in percent)",
              min = min, max = max, value = min , round = -1,
              sep = "" , post = "%", ticks = FALSE
          )

最佳答案

您必须为 step 指定一个 round 才能工作:

library(shiny)
min_Er <- 20.31
max_Er <- 23.59
shinyApp( ui = fluidPage(sliderInput("Er1", "Rounding doesn't work",
                                     round = -2, step = NULL,
                                     min = min_Er,
                                     max = max_Er,
                                     value = min_Er,
                                     sep = "" , post = "%", ticks = FALSE),

                         sliderInput("Er2", "Rounding works",
                                     round = -2, step = 0.01,
                                     min = min_Er,
                                     max = max_Er,
                                     value = min_Er,
                                     sep = "" , post = "%", ticks = FALSE)
), server=function(input, output, session){
  observe(print(input$Er1))
  observe(print(input$Er2))
})

r  Shiny 的滑块输入轮-LMLPHP

否则,正如@Ryan Morton 所评论的,如果您对 minmax 使用整数,即使 round step = NULL ing 也会工作:
library(shiny)
min_Er <- 20.31
max_Er <- 23.59
shinyApp(ui = fluidPage(sliderInput("Er1", "Rounding doesn't work",
                                    round = TRUE,
                                    min = min_Er,
                                    max = max_Er,
                                    value = min_Er,
                                    sep = "" , post = "%", ticks = FALSE),

                        sliderInput("Er2", "Rounding works",
                                    round = TRUE,
                                    min = floor(min_Er),
                                    max = ceiling(max_Er),
                                    value = min_Er,
                                    sep = "" , post = "%", ticks = FALSE)
), server=function(input, output, session){
  observe(print(input$Er1))
  observe(print(input$Er2))
})

r  Shiny 的滑块输入轮-LMLPHP

关于r Shiny 的滑块输入轮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42675102/

10-12 17:37