Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

library(shiny)
library(nycflights13)

ui <- fluidPage(
  wellPanel(
    fluidRow(
      column(12, offset = 0,
        titlePanel("Look up airports"))),
    fluidRow(
      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.

like image 215
Moose on Mars Avatar asked Nov 21 '16 00:11

Moose on Mars


1 Answers

See https://github.com/rstudio/shiny/issues/412.

You can change the maximum number of options like so:

selectizeInput(inputId = "airportCode", label = "", choices = NULL,
  options = list(placeholder = "Type airport code",
    maxOptions = 2000)
  )
like image 191
Weihuang Wong Avatar answered Sep 29 '22 16:09

Weihuang Wong