I have a dataframe with two columns. I want the "id" column to be unique, and the value for the non-repeated id put the same value, and for the repeated id that the value is NA.
library(data.table)
DT <- data.table(id = c(1,2,3,3,4,5,5), value = c(17,13,8,NA,9,NA,11))
DT
id value
1: 1 17
2: 2 13
3: 3 8
4: 3 NA
5: 4 9
6: 5 NA
7: 5 11
Expected output
id value
1: 1 17
2: 2 13
3: 3 NA
4: 4 9
5: 5 NA