I have a data.table DT with 2 columns: ID, QTY
ID QTY
000001 0
000002 1
000002 2
000004 0
000005 1
000006 2
I want to update the Qty column for those rows where Qty is greater than 1 and replace the corresponding Qty value with 1. This is a trivial task that can be performed by using sapply or simply using which command on the column. But I want to know if this can be achieved using the data.table[i,j,by/keyby,.SD] options.
Expected Output:
ID QTY
000001 0
000002 1
000002 1
000004 0
000005 1
000006 1