【问题标题】:Any 'large' data frame crashes R DataTable package - is there a solution? [duplicate]任何“大”数据框都会导致 R DataTable 包崩溃 - 有解决方案吗? [复制]
【发布时间】:2019-11-18 00:40:30
【问题描述】:
library(DT)
library(nycflights13)
datatable(flights)
#> Warning message:
#> In instance$preRenderHook(instance) :
#>   It seems your data is too big for client-side DataTables.
#>   You may consider server-side processing:
#>   https://rstudio.github.io/DT/server.html

当我运行上面的代码时,R Studio 冻结,显然挂起,因为 nycflights13::flights 数据框对于 DT 包来说太大了。

I found this stackoverflow question 建议将所有内容都包含在renderDataTable({}) 中作为解决方案,但这似乎无济于事。我什至可以正确包装东西吗?

renderDataTable({flights})
renderDataTable({datatable(flights)})

解决办法是什么?

【问题讨论】:

    标签: r datatables dt


    【解决方案1】:

    这似乎适合我:

    library(DT)
    library(data.table)
    library(nycflights13)
    TEST<-as.data.frame(flights)
    TEST<-setDT(TEST)
    class(TEST)
    

    【讨论】:

    • 我先创建了一个dataframe,我没有使用datatable(flights)。它对我来说没有崩溃。
    • 谢谢我刚刚注意到,但datatable(TEST) 似乎有同样的问题,并为我冻结了 R 和 R Studio。在几台机器上试过。你能试试datatable(flights)吗?也许你的电脑上也可以这样,在你的情况下创建TEST是不必要的。
    • 它确实给出了一个错误“看起来你的数据对于客户端数据表来说太大了......”。可以先创建一个data.frame吗?
    • 我按照你上面的例程,然后是datatable(TEST),但 R 仍然冻结。我在各种机器上尝试过 Windows 和 Linux,但它一直冻结一切。感谢您的尝试,这在某些情况下似乎有效。
    【解决方案2】:

    您需要运行一个闪亮的(或其他)服务器。根据Yihui's answer over here

    ---
    title: "The server-side processing mode for DT in R Markdown"
    runtime: shiny
    output: html_document
    ---
    
    ```{r}
    library(DT)
    library(nycflights13)
    renderDT(flights)
    ```
    

    【讨论】:

      猜你喜欢
      • 2021-01-07
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      • 1970-01-01
      • 2012-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多