微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决警告:使用服务器端选择来大幅提高 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 部分中的示例进行操作。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。