警告:使用服务器端选择来大幅提高 RShiny 的性能

问题描述

在 RShiny 应用程序中,我收到警告消息 Warning message: The select input "the_input_id" contains a large number of options; consider using server-side selectize for massively improved performance. See the Details section of the ?selectizeInput help topic.

我有一个长度 == 3000 的命名向量 namelist 用于下拉选项。我已经尝试了以下两件事来摆脱这个警告:

用户界面

selectizeInput(
  inputId = 'the_input_id',label = 'Player 1 Search:',choices = namelist,selected = NULL,options = list(placeholder = 'Please select an option below',onInitialize = I('function() { this.setValue(""); }'))
)

uIoUtput(outputId = 'this_id')

服务器

updateSelectizeInput(session = session,inputId = 'the_input_id',server = TRUE,onInitialize = I('function() { this.setValue(""); }')),selected = ""
                           )

output$this_id<-renderUI ({
    selectizeInput(inputId = 'this_id',"Player 2 Search:",namelist,options = list(
                     placeholder = 'Please select an option below',onInitialize = I('function() { this.setValue(""); }')
                   ))
})

the_input_id方法是在 UI 中使用 selectizeinput(),在服务器中使用 updateSelectizeinput()(我认为这是服务器端选择的正确方法)。 this_id方法是在 UI 中使用 uIoUtput(),在服务器上使用 renderUI + selectizeInput。这两种方法都给出了我在上面发布的相同警告消息。如何解决此问题/以消除此警告消息。

解决方法

我认为问题在于您仍在使用 choices = namelist 在 UI 中生成选项列表。

尝试改用 choices = NULL

要使其正常工作,请按照“服务器端选择”of this guide 部分中的示例进行操作。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...