[Rd] simplify2array assumes non-NA dim() -- base or method bug?

Michael Chirico ch|r|com @end|ng |rom goog|e@com
Thu Aug 25 04:51:42 CEST 2022


If any component of the dim() returned as c.dim here[1] are missing,
simplify2array() errors inscrutably (specifically, because the last &&
condition is missing):

Error in if (higher && length(c.dim <- unique(lapply(x, dim))) == 1 &&  :
  missing value where TRUE/FALSE needed

At root here is that dim.tbl_lazy ({dbplyr} package method [2]) very
intentionally neglects to count the # of rows in the result -- the
whole point of a lazy table is to avoid calculating full queries
unless specifically requested, so the # of rows is left as missing,
i.e., there _is_ a quantity of rows, but the exact number is not
known.

That seems to me like a proper usage of NA, and hence this is a
simplify2array() bug, but I am curious other thoughts here before
attempting a patch.

[1] https://github.com/r-devel/r-svn/blob/2d4f8c283d53ff2c98d92c7b77b11e652297742c/src/library/base/R/sapply.R#L46-L48
[2] https://github.com/tidyverse/dbplyr/blob/36b146e36d6d9af215dc48e60862d4b807b9e606/R/tbl-lazy.R#L45-L47



More information about the R-devel mailing list