1

Is there any way for shiny input which looks like slider to have initial NULL or NA value? Both sliderInput and sliderTextInput don't allow for their default value to be null.

I'm well aware that selectInput allows for that (by defaulting to character(0)) but its visual flair isn't valid for application I have been working on.

Their values need to be read after actionButton input, where some checks will be made to make sure all inputs were adjusted by the user.

I have some fundamentals of javascript, but need some direction on how to create a workaround.

Example minimal app:

library(shiny)
library(shinyWidgets)

UI <- fluidPage(
  
  sliderInput(
    "test_1",
    "Testing sliderInput",
    min = 1,
    max = 5,
    value = 3 # don't allow leaving empty, NA or NULL
  ),
  
  sliderTextInput(
    "test2",
    "Testing sliderTextInput",
    choices = c("1 - Least",
                "2 - Less",
                "3 - Middle",
                "4 - More",
                "5 - Most"),
    selected = NULL # allows NULL, but takes the first of 'choices' either way
  )
  
)

server <- function(input, output, session) {
  
}

shinyApp(UI, server)
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
M_Kos
  • 78
  • 8

0 Answers0