Skip to content

dcast.data.table should error when fun.aggregate value for missing combinations is of length 0, but no fill value is provided #715

@arunsrinivasan

Description

@arunsrinivasan

While fixing #713, came across another potential bug that needs to be fixed.

library(data.table)
DT <- data.table(id=rep(1:2, c(3,2)), k=c(letters[1:3], letters[1:2]), v=1:5)

Now, if we do:

dcast.data.table(DT, id ~ k, fun.aggregate=last)

this should result in error, beause last(integer(0)) is integer(0), which is not of length 1. The error message should indicate this and provide the solution that the function needs to be modified or fill= argument has to be explicitly set. Ex:

dcast.data.table(DT, id ~ k, fun.aggregate=last, fill=NA)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions