I have this data frame:
> df
c1 c2
1 1 b
2 2 a
3 3 a
4 4 a
5 3 a
6 2 b
7 6 a
8 4 b
9 8 b
10 7 a
So for i=3, the output should be the 3rd lowest values of "c1" for both levels of "c2"
c1 c2
3 a
4 b
Essentially a variation on a theme:
aggregate(c1 ~ c2, df, function(x) sort(x)[3])
# c2 c1
# 1 a 3
# 2 b 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With