I have a Shiny sliderInput in my application in which one can choose a year between 2000 and 2022. However, I do not have any data for 2021 which is why I would like to exclude that year and to not have it shown so that the user cannot choose 2021 on the slider because it should not even show up (so the values should be 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2022).
I've searched on here before but did not find something similar. Can anyone help?
As r2evans already points out in the comments, We can use shinyWidgets::sliderTextInput
:
library(shiny)
library(shinyWidgets)
shinyApp(ui = fluidPage(
sliderTextInput(
inputId = "mySliderText",
label = "Choose Year:",
choices = c(2000:2020, 2022),
selected = 2022
),
textOutput("sliderout")
),
server = function(input, output) {
output$sliderout <- renderText(input$mySliderText)
})