【问题标题】:DataTables for R: "warning: `dim<-.vctrs_list_of()` not supported"R 的数据表:“警告:不支持`dim<-.vctrs_list_of()`”
【发布时间】:2020-07-21 07:08:50
【问题描述】:

我是 DataTables 的新手,但对它的强大功能感到惊讶,并设法创建了几个不同的表并在 Shiny 仪表板中使用它们。目前我正在尝试实现this table,并在更新了一些代码后设法做到了(请参阅我自己在线程中的答案)。

但是,在将决赛桌插入 Shiny 时,像这样......

shinyApp(
  ui = fluidPage(
    DT::dataTableOutput("table")
  ),
  server = function(input, output) {
    output$table = DT::renderDataTable({final_table})
  }
)

...我收到错误 DataTables warning: table id=DataTables_Table_0 - 'dim&lt;-.vctrs_list_of()' not supported. 只需在 RStudio 中运行 final_table 即可完全按照预期生成 DataTable。使用 shiny 中的同名函数而不是 DT 会返回一个空白页。

我从我必须对上面的链接答案所做的更改之一中识别出vctrs_list_of(这是因为tidyrnest() 这些天返回一个嵌套列vctrs_list_of 而不是@987654331 @),所以我想那里发生了一些事情。

但是,使用“检查元素”时,我只看到一个 Uncaught TypeError: Cannot read property 'length' of undefined JS 错误,它链接到大量 DataTables JS 脚本中的一些晦涩的行。该警告未包含在 DataTables 的文档中。

任何线索/提示将不胜感激!

【问题讨论】:

    标签: r shiny datatables


    【解决方案1】:

    我终于解决了这个问题,通过运行 class(table$data) &lt;- "list" 将相关列的类从 vctrs_list_of 强制更改为 list

    (注意:它需要对链接示例的 JavaScript 代码进行一些更改,因为现在为 list 的列的结构略有不同。)

    如果有人对这里发生的事情有更准确的解释,很想听听!

    【讨论】:

      猜你喜欢
      • 2021-12-05
      • 1970-01-01
      • 2022-07-28
      • 1970-01-01
      • 1970-01-01
      • 2019-11-10
      • 2010-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多