Takes "n" values from the head or tail of a sorted vector. Utilizes the
"partial" argument from sort
for increased efficiency.
sortEnds(invec, n, where = "head")
invec | The input vector |
---|---|
n | The number of values desired |
where | Either |
A sorted vector of length = n
The "tail"
approach may not be consideraby faster than
the standard approach.
Ananda Mahto
#> [1] 13 14 20sortEnds(x, 3, "tail")#> [1] 296 298 299#> [1] 13 14 20#> [1] 296 298 299