Q:

Keep less recent duplicate row in R

So, I have a dataset with bill numbers, day, month, year, and aggregate value. There are a bunch of bull number duplicates, and I want to keep the first ones. If there is a duplicate with the same day, month, and year, I want to keep the one with the highest amount in aggregate value.
For example, if the dataset now looks like this:
Bill Number   Day   Month    Year   Ag. Value
   1           10     4       1998     10
   1           11     4       1998     14
   2           23     11      2001     12
   2           23     11      2001     9
   3           11     3       2005     8
   3           12     3       2005     9
   3           13     3       2005     4

I want the result to look like this:
Bill Number  Day  Month  Year  Ag. Value
    1         10    4     1998    10
    2         23    11    2001    12
    3         11    3     2005    8

I'm not sure if there is a command I can use and just introduce all these arguments or if I should do it in stages, but either way I'm not sure how to begin. I used duplicate() and unique() and then got stuck.
Thanks!

A:

library( data.table )

dt <- fread("Bill_Number   Day   Month    Year   Ag_Value
1           10     4       1998     10
1           11     4       1998     14
2           23     11      2001     12
2           23     11      2001     9
3           11     3       2005     8
3           12     3       2005     9
3           13     3       2005     4", header = TRUE)

dt[ !duplicated( Bill_Number), ]  

#    Bill_Number Day Month Year Ag_Value
# 1:           1  10     4 1998       10
# 2:           2  23    11 2001       12
# 3:           3  11     3 2005        8

or
dt[, .SD[1], by = .(Bill_Number) ]  #other approach, a bit slower

