starting to replace ddply with data.table