我如何在 Shiny 中用 rhandsontable 处理一个空的 table?

How do I handle an empty table with rhandsontable in Shiny?

删除我的 rhandsondtable 中的最后一行时,出现以下错误:

Warning: Error in matrix: 'data' must be of a vector type, was 'NULL'
Stack trace (innermost first):
    61: matrix
    60: <Anonymous>
    59: do.call
    58: hot_to_r
    57: observerFunc [#64]
    2: runApp
    1: editTable [#126]

当我 运行 this blog post 中的代码时,同样的事情发生了。我正在使用此代码进行实验。

我希望能够阻止这种情况。我愿意接受不同的选择,例如

我试过使用 minSpareRows 选项,但这会导致以下错误

Warning: Error in row.names<-.data.frame: invalid 'row.names' length
Stack trace (innermost first):
    63: row.names<-.data.frame
    62: row.names<-
    61: rownames<-
    60: <Anonymous>
    59: do.call
    58: hot_to_r
    57: observerFunc [#64]
    2: runApp
    1: editTable [#127]

我现在不想检查 input$hot 中是否有行,并且由于 hot_to_r 函数失败了,我无法使用数据框来完成它.

任何有关如何处理我的 "empty" table 问题的帮助将不胜感激。

input$hot 是一个包含三项的列表,第一项 input$hot$data 包含 table 数据。因此,您可以检查 length(input$hot$data) 以确定剩余的行数。