title: Select first row for each id for each year
body: <p>Say I have a dataset below where each id can have multiple records per year. I would like to keep only the id's most recent record per year.</p>
  <pre><code>id&lt;-c(1,1,1,2,2,2)
  year&lt;-c(2020,2020,2019,2020,2018,2018)
  month&lt;-c(12,6,4,5,4,1)
  
  have&lt;-as.data.frame(cbind(id,year,month))
  
  have
    id year  month
    1  2020    12
    1  2020     6
    1  2019     4
    2  2020     5
    2  2018     4
    2  2018     1
  
  </code></pre>
  <p>This is what would like the dataset to look like:</p>
  <pre><code>want
  
    id year   month
    1  2020     12
    1  2019      4
    2  2020      5
    2  2018      4
  </code></pre>
  <p>I know that I can get the first instance of each id with this code, however I want the latest record for each year.</p>
  <pre><code>want&lt;-have[match(unique(have$id), have$id),]
  
    id year  month
    1  2020    12
    2  2020     5
  </code></pre>
  <p>I modified the code to add in year, but it outputs the same results as the code above:</p>
  <pre><code>want&lt;-have[match(unique(have$id,have$year), have$id),]
  
    id year  month
    1  2020    12
    2  2020     5
  
  </code></pre>
  <p>How would I modify this so I can see one record displayed per year?</p>