0

I like the features of DT package, it addresses most of my issues. One thing I noticed with DT::renderDataTable compared to previous one is that it is very slow when filter=top is used. I understand that it has to gather the values for factor columns and date columns, but is defeating the purpose. It feels like I have to chose between these additional features vs speed of rendering the page.

Is this normal or is there any other way to improve the speed of rendering the page while using DT with filter=top?

NOTE : I'm using that on 32 column 350k row data table

Here is the structure of rb:

Classes ‘data.table’ and 'data.frame':  357574 obs. of  32 variables:
  $ 1col : chr  "00000001175" "00001050760" "00002020102" "00002050202" ...
  $ 2col : Factor w/ 6 levels 
  $ 3col : Factor w/ 22116 levels 
  $ 4col : Factor w/ 4 levels 
  $ 5col : Factor w/ 22 levels 
  $ 6col : Factor w/ 11 levels 
  $ 7col : Factor w/ 2 levels 
  $ 8col : Factor w/ 7 levels 
  $ 9col : Factor w/ 2 levels 
  $ 10col: Factor w/ 2 levels 
  $ 11col: Factor w/ 114 levels 
  $ 12col: Factor w/ 2 levels 
  $ 13col: Factor w/ 258 levels 
  $ 14col: Factor w/ 27 levels 
  $ 15col: Factor w/ 32 levels 
  $ 16col: Factor w/ 314 levels 
  $ 17col: Factor w/ 2751 levels 
  $ 18col: Factor w/ 7 levels 
  $ 19col: Factor w/ 3952 levels 
  $ 20col: Factor w/ 4 levels 
  $ 21col: Factor w/ 5389 levels 
  $ 22col: Factor w/ 11 levels 
  $ 23col: Factor w/ 27 levels 
  $ 24col: Factor w/ 22 levels 
  $ 25col: Factor w/ 2491 levels 
  $ 26col: Factor w/ 113 levels 
  $ 27col: Factor w/ 258 levels 
  $ 28col: Factor w/ 32 levels
  $ 29col: Factor w/ 6 levels 
  $ 30col: chr  "ABC" "CDE" 
  $ 31col: Factor w/ 2679 levels 
  $ 32col: Factor w/ 8333 levels 

As a test, I converted any factor column above that has more than 100 levels to character format and that improved rendering. Rendering time came down from 40 t0 6secs

Sri
  • 1,130
  • 1
  • 15
  • 31
  • Is it slow to render the table initially, or is it slow for the table to respond when you interact with it? How slow it is? – Yihui Xie Jul 09 '15 at 01:44
  • Without `filter=top` it takes 1 second to render the table and with `filter=top` it takes around 40 seconds – Sri Jul 09 '15 at 14:13
  • Can you provide a reproducible example? I don't see the slowness with this example: `d = as.data.frame(matrix(rnorm(32*350000),ncol=32)); library(shiny); library(DT); shinyApp( ui = fluidPage(dataTableOutput('foo')), server = function(input, output) { output$foo = renderDataTable(d, filter='top') } )` – Yihui Xie Jul 09 '15 at 18:59
  • Here is the statement I'm using from server.R file : `output$table1 <- DT::renderDataTable({ datatable(rb, #options=list(dom='Rlrtip'), rownames=F,filter='top' ) })` If I comment the `filter='top'` it runs fast – Sri Jul 09 '15 at 19:23
  • Please post a minimal, self-contained, and reproducible example (like what I did in my previous comment), instead of a fragment (you can edit your post to include the example). Since I have no idea what is `rb`, there is no way for me to reproduce your problem. – Yihui Xie Jul 09 '15 at 19:46
  • Unfortunately, I cannot share anything about `rb` due to vendor restrictions, but I will update the post to provide structure details of `rb`. – Sri Jul 09 '15 at 19:54
  • I was not asking you to post the content of `rb`. I have showed you how to make a minimal self-contained reproducible example in my first comment: you can simply use random numbers. Please read http://stackoverflow.com/q/5963269/559676 – Yihui Xie Jul 09 '15 at 21:13

0 Answers0