Row index of the n-highest value
Posted: Mon May 11, 2020 6:04 pm
How do I find the row index of the n-highest value in a group similar to @rimax (n = 2nd, 3rd,...etc.)? Thanks.
Code: Select all
matrix tmp1 = @transpose(@colcumsum(@ones(@columns(g), @rows(g))))
matrix tmp2 = @rowranks(@convert(g), "d")
for !i = 1 to @rows(tmp1)
rowplace(tmp1, @rapplyranks(@rowextract(tmp1, !i), @rowextract(tmp2,!i)), !i)
next