How to use sliderInput to enter more than 2 values ​​in Rshiny

Traditionally, the sliderInput function

sliderInput(inputId, label, min, max, value, step = NULL, round = FALSE, format = NULL, 
locale = NULL, ticks = TRUE, animate = FALSE, width = NULL, sep = ",", 
pre = NULL, post = NULL, timeFormat = NULL, timezone = NULL, dragRange = TRUE)

If i point

sliderInput("range","range",min=-3,max=3,value=c(-1,1))

it enters a range from -1 to 1. However, there is a function that takes an argument format like days_included = c (-2, -1,0,1,2). In this case, I cannot make this function work if I installed

sliderInput("range","range",min=-3,max=3,value=c(-2,2)) 

as it really does not match the required format. So this is my question, anyway, for this function to work? I tried the step argument inside sliderInput but could not.

+4
source share
1 answer

, , , , , , : seq.

, input$range[1]:input$range[2]


:

library(shiny)
rm(ui) ; rm(server)

ui <- fluidPage(
  br(),
  sliderInput("range","range",min = -3, max = 3, value = c(-2, 2)),
  div(verbatimTextOutput("out1"), style = "width: 300px;")
)

server <- function(input, output) { 

  output$out1 <- renderText({
    # seq.int(from = input$range[1], to = input$range[2])
    input$range[1]:input$range[2]
  })

}
shinyApp(ui, server)
+3

Source: https://habr.com/ru/post/1652663/


All Articles