I have a data.frame with several columns (17).
Column 2 have several rows with the same value, I want to keep only one of those rows, specifically the one that has the maximum value in column 17.
For example:
A B
'a' 1
'a' 2
'a' 3
'b' 5
'b' 200
Would return
A B
'a' 3
'b' 200
(plus the rest of the columns)
So far I’ve been using the unique function, but I think it randomly keeps one or keeps just the first one that appears.
** UPDATE **
The real data has 376000 rows. I’ve tried the data.table and ddply suggestions but they take forever. Any idea which is the most efficient?
A solution using package
data.table: