I have data that is structured similarly to the following:
a<-data.frame(ID=c(1,2,2,2,3,3),Date=as.Date(c("2017-01-01","2017-01-02","2017-01-03","2017-01-04","2017-01-05","2017-01-06")))
print(a)
ID Date
1 2017-01-01
2 2017-01-02
2 2017-01-03
2 2017-01-04
3 2017-01-05
3 2017-01-06
I want to remove any repeat ID
and keep the most recent one based on Date
to obtain the following:
b<-data.frame(ID=c(1,2,3),Date=as.Date(c("2017-01-01","2017-01-04","2017-01-06")))
print(b)
ID Date
1 2017-01-01
2 2017-01-04
3 2017-01-06
Thank you!