I am looking for a way to identify and replace row-wise duplicate values in a data.table
with NA
.
The following answer helps me identify row-wise duplicates...
Removing duplicate values row-wise in R
...but I am looking for a way to address those duplicates.
PROBLEM
(dt <- data.table(X = 1:10, Y = seq(1, 19, by = 2), Z = c(1, rep(3, 9))))
X Y Z
1: 1 1 1
2: 2 3 3
3: 3 5 3
4: 4 7 3
5: 5 9 3
6: 6 11 3
7: 7 13 3
8: 8 15 3
9: 9 17 3
10: 10 19 3
EXPECTED RESULT
X Y Z
1: 1 NA NA
2: 2 3 NA
3: 3 5 NA
4: 4 7 3
5: 5 9 3
6: 6 11 3
7: 7 13 3
8: 8 15 3
9: 9 17 3
10: 10 19 3
Please help