I have a data.frame object in R and need to:
- Group by col_1
- Select rows from col_3 such that col_2 value is the second largest one (if there is only observation for the given value of col_1, return 'NA' for instance).
How can I obtain this?
Example:
scored      xg  first_goal scored_mane
1       1 1.03212     Lallana           0
2       1 2.06000        Mane           1
3       2 2.38824   Robertson           1
4       2 1.64291        Mane           1 
Group by "scored_mane", return values from "scored" where "xg" is the second largest. Expected output: "NA", 1
 
    