Moose on Mars Moose on Mars - 1 year ago 95
R Question

Display all values in a Shiny selectInput box (1000+)

I am working an a Shiny app where I want to allow the user to pick from a longer list of genes (~1800) and then have corresponding graphs for the selected gene displayed. My problem is that I cannot get Shiny to display the whole list of genes available to select from in the drop-down menu of the selectInput box, it seems that only the first 1000 or so get displayed.

Then I found a promising solution using server-side selectize, where all the available options get displayed when the user starts typing into the select box. However, when the user is not typing, the drop-down menu still doesn´t display more than the first 1000 genes, which can suggest that there are not more options available.

I recreated the problem with a different data set (1396 airport codes) for illustration purposes:


ui <- fluidPage(
column(12, offset = 0,
titlePanel("Look up airports"))),
column(3, offset = 0,
selectizeInput(inputId = "airportCode", label = "", choices = NULL,
options = list(placeholder = "Type airport code"))))

server <- function(input, output, session) {
updateSelectizeInput(session, "airportCode",
choices = as.vector(airports$faa), server = TRUE)

shinyApp(ui = ui, server = server)

When you don´t type into the select box, the last airport code displayed in the drop-down menu is only "PAM". Yet when you start typing you can get all the way down to the last one "ZYP", which I think this is rather confusing to the user.

Best would be to have all of the values appear in the drop-down menu, if that is somehow feasible. Otherwise have none at all listed there and have them only show up when you start typing.

Answer Source


You can change the maximum number of options like so:

selectizeInput(inputId = "airportCode", label = "", choices = NULL,
  options = list(placeholder = "Type airport code",
    maxOptions = 2000)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download