I have data in a similar structure as shown below. This is in R code but if you can just write the query without the R stuff thats fine too.
I have multiple groups and
I don't know R but your SQL would be something like:
SELECT * FROM YourTable as A
INNER JOIN (SELECT GROUPS, MAX(DATES) AS MAX_DATE FROM YourTable GROUP BY GROUPS) AS B
ON A.GROUPS = B.GROUPS AND B.MAX_DATE = A.DATES
This would identify the max date for each group (derived table B) then match them with the records from the main table (table A).