The current error message is this:
Error in dcast.data.table(test.table, as.formula(paste(class.col, "+", :
retFirst must be integer vector the same length as nrow(i)
A replacement candidate recommended by Arun is this:
Error: fun.aggregate should return, for each unique group (from formula's LHS),
a length 1 vector, but returns length=2 for a group.
This SO thread has a reproducible example and background describing the issue.