I have a dataframe of several columns i need to filter by one column value (let's call it col1) but i need to pick the row that has the least value in another column (e.g., col2). I know how to take distinct rows by a column value (basically, dplyr's distinct(col1)), but I'm not sure how it behaves when choosing the line to return from multiple lines, and I don't know how to guide it.
For example, what I need is given this dataframe:
col1 col2
a 10
b 12
a 8
b 14
a 15
c 6
a 3
return the unique lines by col1 that have the least value in col2, i.e.:
col1 col2
a 3
b 12
c 6