Stephanie L. answered 01/14/22
Full-time Data Scientist
Fastest way that I can think of to specifically find the second highest value from a vector:
You can replace max() with min() if you'd like to go the opposite way.
Other way that I would prefer:
- Convert the vector to a column in a dataframe. Sort the dataframe in ascending or descending order and reset the index. Create a rank column that mirrors that index. Now you have a rank column from which you can subset.
But like you said, you can also sort the vector in descending or ascending order, then select by position.