在Shiny selectInput框中显示所有值(1000+) [英] Display all values in a Shiny selectInput box (1000+)

查看:27
本文介绍了在Shiny selectInput框中显示所有值(1000+)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在工作一个Shiny应用程序,我想允许用户从更长的基因列表中选择(约1800个),然后显示所选基因的对应图.我的问题是我无法让Shiny显示在selectInput框的下拉菜单中可供选择的基因的整个列表,似乎只显示了前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.

然后,我找到了一种使用服务器端选择的有前途的解决方案,当用户开始在选择框中键入内容时,将显示所有可用选项.但是,当用户不键入内容时,下拉菜单显示的内容仍然不会超过前1000个基因,这表明没有更多的可用选项.

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.

出于说明目的,我使用不同的数据集(1396个机场代码)重新创建了问题:

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)

不输入选择框时,下拉菜单中显示的最后一个机场代码仅为"PAM".但是,当您开始键入内容时,您可以一直沿用到最后一个"ZYP",我认为这对用户而言相当混乱.

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.

推荐答案

请参见 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)
  )

这篇关于在Shiny selectInput框中显示所有值(1000+)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆