Reputation: 10441
In an RShiny app, I am receiving the warning message 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.
I have a named vector namelist of length == 3000 that is used for the dropdown choices. I've tried the following two things to get rid of this warning:
ui
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')
server
updateSelectizeInput(session = session, inputId = 'the_input_id', label = 'Player 1 Search:', choices = namelist, server = TRUE,
options = list(placeholder = 'Please select an option below', 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 approach for the_input_id is to use a selectizeInput() in the UI, and an updateSelectizeInput() in the server (I thought this was the correct approach for server-side selectize). The approach for this_id is to use an uiOutput() in the UI, and a renderUI + selectizeInput on the server. Both of these approaches give the same warning message that I posted above. How can I resolve the issue / to get rid of this warning message.
Upvotes: 7
Views: 5656
Reputation: 11
Even when you do render it in server it will not solve your problem because this error may mean that the namelist
contain a large number of duplicates, for better performance it's better to render selectize input in the server reason of its size.
namelist
should not contain duplicates, and I guess the following will fix it:
choices = unique(namelist)
or choices = unique(factor(namelist))
Server:
updateSelectizeInput(
session,
inputId = 'id',
label = '',
choices = unique(namelist)
)
UI:
shiny::selectizeInput(
inputId = "id",
label = NULL,
choices = '',
options = list(...)
)
Upvotes: 0
Reputation: 33802
I think the issue is that you are still generating the list of options in the UI, using choices = namelist
.
Try using choices = NULL
instead.
To get it working, follow the example in the section "Server-side selectize" of this guide.
Upvotes: 6