Perhaps this is intentional, but it seems to me a more natural solution to this question on SO would be:
shoppinglists[ , if (.N>=3)
.(triplet = combn(items, 3, simplify=FALSE)),
by=consumer][ , .N, by=triplet][order(-N)]
But if we try and use the list column in by we get an error:
Error in`` [.data.table(shoppinglists[, if (.N >= 3) list(triplet = combn(items,`:
The items in the`by`or`keyby`list are length`(3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3)`. Each must be same length as rows in`x`or number of rows returned by`i` (18).
As cryptic as this error is, I think by is having trouble identifying unique lists (perhaps this is by design).
Is there no way to do use a list column in by?
Perhaps this is intentional, but it seems to me a more natural solution to this question on SO would be:
But if we try and use the
listcolumn inbywe get an error:As cryptic as this error is, I think
byis having trouble identifying unique lists (perhaps this is by design).Is there no way to do use a
listcolumn inby?