Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R shinny-renderDataTable渲染大型矩阵太慢_R_Shiny_Dt - Fatal编程技术网

R shinny-renderDataTable渲染大型矩阵太慢

R shinny-renderDataTable渲染大型矩阵太慢,r,shiny,dt,R,Shiny,Dt,我正在制作一个闪亮的应用程序,它使用renderDataTable绘制一个巨大的矩阵。 矩阵约为30行500列。我需要renderDataTable来快速绘制矩阵。现在大约2-3秒(对于这个应用来说太慢了)。有没有加快渲染速度的方法 下面是一个简单的例子: library(shiny) library(DT) ui <- fluidPage( br(), actionButton(inputId = 'Update.button', label = "Update",width

我正在制作一个闪亮的应用程序,它使用renderDataTable绘制一个巨大的矩阵。 矩阵约为30行500列。我需要renderDataTable来快速绘制矩阵。现在大约2-3秒(对于这个应用来说太慢了)。有没有加快渲染速度的方法

下面是一个简单的例子:

library(shiny)
library(DT)

ui <- fluidPage( 
  br(),
  actionButton(inputId = 'Update.button', label = "Update",width = 100),
  br(),br(),
  dataTableOutput(outputId = "myTable")
            )


server <- function(input, output){

myMatrix <- eventReactive(
           input$Update.button, 
           cbind(paste('Name',1:30,sep =''), replicate(500, sample(x=10:100,30)*10^5))
                        )

output$myTable <- DT::renderDataTable({

COLS <-  1:(ncol(myMatrix())-1)
WIDTH <- '60px' ## WIDTH is reactive and depends on user input (let's fix it here to 60px)

DT::datatable(data = myMatrix(), rownames = TRUE,class = 'compact',
 options = list(pageLength = 30,paging = FALSE,searching = FALSE, scrollX = TRUE, ordering=FALSE, info=FALSE,
   autoWidth=TRUE,columnDefs = list(list(className = "dt-center",targets = COLS,width = WIDTH), # apply center and WIDTH on every column except first one
                                   list(className = "dt-center", target = 0)) ## center first column
          ))})

}

shinyApp(ui = ui,server = server)
库(闪亮)
图书馆(DT)

ui尝试选择
server=FALSE

output$myTable <- renderDT({

  COLS <-  1:(ncol(myMatrix())-1)
  WIDTH <- '60px' ## WIDTH is reactive and depends on user input (let's fix it here to 60px)

  datatable(data = myMatrix(), rownames = TRUE,class = 'compact',
            options = list(pageLength = 30,
                           paging = FALSE,
                           searching = FALSE, 
                           scrollX = TRUE, 
                           ordering=FALSE, 
                           info=FALSE,
                           autoWidth=TRUE,
                           columnDefs = list(list(className = "dt-center",
                                                  targets = COLS,
                                                  width = WIDTH), # apply center and WIDTH on every column except first one
                                             list(className = "dt-center", 
                                                  target = 0)) ## center first column
            ))}, server = FALSE)

output$myTable绝对更快。谢谢:)