When durations are computed in data.table (v1.9.2), the wrong units can be printed with POSIXct arithmetic. It seems the first units are chosen.
require(\"da
This could be viewed as operator error, because your table is (automatically) displaying a numeric equivalent of a difftime, but you are not specifying which units to display the answer in. In most cases where you wish to export/display difftime values the desired units should be specified in an explicit conversion to numeric. E.g.
dt[ , as.numeric( max(time) - min(time), units="hours" ), by=id]