我有一個R閃亮的滑塊輸入問題。 「圓形特徵」不起作用,您可以在in this picture中看到。我做錯什麼了嗎 ?r閃亮的滑塊輸入輪
sliderInput("Er", "Choose expected return (in percent)",
min = min, max = max, value = min , round = -1,
sep = "" , post = "%", ticks = FALSE
)
我有一個R閃亮的滑塊輸入問題。 「圓形特徵」不起作用,您可以在in this picture中看到。我做錯什麼了嗎 ?r閃亮的滑塊輸入輪
sliderInput("Er", "Choose expected return (in percent)",
min = min, max = max, value = min , round = -1,
sep = "" , post = "%", ticks = FALSE
)
您必須指定一個step
爲round
ING工作:
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))
})
否則,由@Ryan莫頓評論,如果您使用整數的min
和max
,round
ing即使step = NULL
:
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))
})
如果您在將最小值和最大值傳遞給sliderInput()之前嘗試舍入,會發生什麼? –
他們在小數點後一位,它仍然沒有工作。 – Ethan