The latest dev is broken for use cases where j returns NULL but evaluates list(...) either explicitly or implicitly.
data <- data.table(id = rep(1:2, each = 5), x = rnorm(10), y = rnorm(10))
If j evaluates list(...) with different lengths but finally returns NULL
data[, {
if (id %% 2 == 0) {
list(a = 1, b = 2)
} else {
list(a = 0)
}
NULL
}, keyby = id]
An error still occurs:
Error in `[.data.table`(data, , { :
j doesn't evaluate to the same number of columns for each group
And if list(...) of the same lengths are evaluated but returns NULL
data[, {
if (id %% 2 == 0) {
list(a = 1, b = 2)
} else {
list(a = 0, b = 1)
}
NULL
}, keyby = id]
A table is incorrectly produced:
Even if no explicit list(...) is called, error still occurs, which is a typical use case for group plotting:
col <- c("red", "green")
data[, {
matplot(x, y, col = col)
legend("topleft", legend = c("x", "y"), col = col)
NULL
}, keyby = id]
Error in `[.data.table`(data, , { :
Supplied 2 items for column 2 of group 1 which has 4 rows. The RHS length must either be 1 (single values are ok) or match the LHS length exactly. If you wish to 'recycle' the RHS please use rep() explicitly to make this intent clear to readers of your code.
I guess this is related to the recently introduced auto-naming j (#3802)?
The latest dev is broken for use cases where
jreturnsNULLbut evaluateslist(...)either explicitly or implicitly.If
jevaluateslist(...)with different lengths but finally returnsNULLAn error still occurs:
And if
list(...)of the same lengths are evaluated but returnsNULLA table is incorrectly produced:
Even if no explicit
list(...)is called, error still occurs, which is a typical use case for group plotting:I guess this is related to the recently introduced auto-naming
j(#3802)?