Brilliant selectInput is very slow with big data (~ 15,000 records) in the browser

I have this basic brilliant application and it blazes quickly in the Viewer, but when I use the Open in Browser option, it takes some time to select the input.

selectList <- sapply(1:15000, function(x) paste(sample(letters, 10), collapse = ''))
ui <- fluidPage(
  selectInput('mylist', 'Select Something',
              choices = c(Choose = '', selectList),
              selected = 1)
)

server <- function(input, output) {
}

shinyApp(ui = ui, server = server)

According to this topic - https://groups.google.com/forum/#!topic/shiny-discuss/doHpFM6ZOGg , the problem has been fixed in the old branch. The last installation I use is this, and I see the problem of slowness.

packageVersion('shiny')
[1] ‘0.13.2

Any parameters I have to do behave differently?

Additional need:

, . - . , ?

# mylist
selectList1 <- sapply(1:15000, function(x) paste0(x, "_", paste(sample(LETTERS, 10), collapse = '')))
selectList2 <- sapply(1:15000, function(x) paste0(x, "_", paste(sample(letters, 10), collapse = '')))

# ui
ui <- fluidPage(
  selectizeInput(
    inputId = 'mylist', label = 'Select Something',
    choices = NULL,
    selected = 1
  ),
  radioButtons('letterType',
               'Select a Letter Type:',
               choices = c('Upper Case' = 'upper',
                           'Lower Case' = 'lower'),
               selected = 'upper',
               inline = TRUE)
)

# server
server <- function(input, output, session) {
  selectListReactive <- reactive({
    validate(need(is.null(input$letterType), FALSE))
    if (input$letterType == 'upper')
      selectList1
    else
      selectList2
  })
  observeEvent(input$letterType, {
    updateSelectizeInput(session = session, inputId = 'mylist',
                         choices = c(Choose = '', selectListReactive()),
                         server = TRUE)
  })
}

# app
shinyApp(ui = ui, server = server)
+4
2

, updateSelectizeInput server = TRUE , .

library("shiny")
# mylist
selectList <- sapply(1:15000, function(x) paste0(x, "_", paste(sample(letters, 10), collapse = '')))
# ui
ui <- fluidPage(
  selectizeInput(
    inputId = 'mylist', label = 'Select Something',
    choices = NULL,
    selected = 1
  )
)
# server
server <- function(input, output, session) {
  updateSelectizeInput(session = session, inputId = 'mylist', choices = c(Choose = '', selectList), server = TRUE)
}
# app
shinyApp(ui = ui, server = server)

selectizeInput, selectInput

+11

data.table:

library(data.table)
selectList <- as.data.table(sapply(1:15000, function(x) paste(sample(letters, 10), collapse = '')))
ui <- fluidPage(
  selectInput('mylist', 'Select Something',
              choices = c(Choose = '', selectList),
              selected = 1)
)

server <- function(input, output) {
}

shinyApp(ui = ui, server = server)

0

Source: https://habr.com/ru/post/1648266/


All Articles