hi, I have the following dataframe
ID= c(1,1,1,2,2,2,2,3,3)
week = c(1,1,2,1,1,2,2,1,2)
X = c(3.3,4.23,5.6,12,3.1,4.3,5.9,6.1,5.3)
Y = c(1.3,2.4,6.8,5.5,4.3,3,6.6,2.6,5.7)
DF = data.frame(ID,week,X,Y)
I would like to remove rows where 'week' is identical for each 'ID', i.e. the dataframe should read
ID week X Y
1 1 3.30 1.3
1 2 5.60 6.8
2 1 12.0 5.5
2 2 4.30 3.0
3 1 6.10 2.6
3 2 5.30 5.7
So far I have been trying
DF = DF[!(duplicated(DF$ID) & duplicated(DF$week)), ]
but hat doesn't work as expected.
Any ideas would be very welcome. M