3
我正在開發一個閃亮的應用程序,並希望提高滑塊的準確性(滑塊範圍從0到1000,並且很難精確調整滑塊,步長爲1)。我無法在任何地方找到答案。 這是我的滑塊之一代碼:如何在光澤中的sliderInput()上添加加號和減號箭頭?
sliderInput("mean2", "", min=0, max=1000, value=500, step=1)
我正在開發一個閃亮的應用程序,並希望提高滑塊的準確性(滑塊範圍從0到1000,並且很難精確調整滑塊,步長爲1)。我無法在任何地方找到答案。 這是我的滑塊之一代碼:如何在光澤中的sliderInput()上添加加號和減號箭頭?
sliderInput("mean2", "", min=0, max=1000, value=500, step=1)
儘量安排喜歡這樣的代碼:
library(shiny)
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
actionButton("minus", "Minus"),
actionButton("plus", "Plus"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("mean2",
"Number of bins:",
min = 0,
max = 1000,
value = 500,
step= 1)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
server <- function(input, output, session) {
v <- reactiveValues(data = 500)
observeEvent(input$minus, {
v$data <- input$mean2 - 1
updateSliderInput(session,"mean2", value = input$mean2 - 1)
})
observeEvent(input$plus, {
v$data <- input$mean2 + 1
updateSliderInput(session,"mean2", value = input$mean2 + 1)
})
observeEvent(input$mean2, {
v$data <- input$mean2
})
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = v$data + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
shinyApp(ui, server)