I am reading my data in by folder then pulling by a date range.
I am looking to summarize my data by a column but when doing so it is not combining them to produce less rows.
I am using the following code
temptable <- temptable[ ,lapply(.SD, sum), by = .(INV_ITEM_ID),
.SDcols = c("Ext Sale", "Ext Total Cost")]
I have done this with subsets of my data and it can get it to work but not for the full data set.
Any ideas on why this is not summarizing correctly? I would provide a reproducible example but the code seems to work on that.
I can provide other details if needed.
An example of what is going on is lets say we have the following
INV_ITEM_ID, Ext Sale, Ext Total Cost
1234 8 4
1234 2 7
1233 6 4
When I run the above code that is how it returns to me instead of returning it like below
INV_ITEM_ID, Ext Sale, Ext Total Cost
1234 10 11
1233 6 4