Issue with generating the correct output from a table using data.table package

I would suggest starting a new topic witha description of your issues and a reproducible example (reprex)