-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
Inspired by Matt's observation here: e1ac663
DT[topn(score, 5L)]
also looks nicer than DT[order(score)[1:5]]
or DT[order(score)][1:5]
.
A quick search suggests two possible implementations which might be better in one situation or another:
Will take a look at feasibility to implement cleanly.
Just looked now and dplyr
also has top_n
but seems they implement it inefficiently:
dplyr:::top_n_rank
function (n, wt)
{
if (n > 0) {
min_rank(desc(wt)) <= n
}
else {
min_rank(wt) <= abs(n)
}
}
mgahan-he, ben519 and Kamgang-B