Traditionally, a sliderInput function is
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 specify
sliderInput("range","range",min=-3,max=3,value=c(-1,1))
it input a range from -1 to 1. However, there is a function takes an argument format as days_included=c(-2,-1,0,1,2). In this case, I cannot make this function work if I set
sliderInput("range","range",min=-3,max=3,value=c(-2,2))
since it doesn't really match the required format. So this is my question, anyway to make this function work? I tried "step" argument inside sliderInput but failed.
Your slider returns two values and if you want to have, say, all integers in between, you have to create a sequence using these values and :
or with seq
functions.
So basically you need input$range[1]:input$range[2]
Minimal example:
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With