least.k {MuViCP} | R Documentation |
Functions to find the few smallest elements in a vector.
Description
Given a numeric vector, these functions compute and return the few
smallest elements in it. The number of elements returned is specified as
either a definite number (k
) or as a proportion of the vector
length (p
). The variant functions (which.*
), accomplish
the same task, but return instead the position of such elements in the vector.
Usage
least.k(x, k)
least.p(x, p)
which.least.k(x, k)
which.least.p(x, p)
Arguments
x |
The numeric vector. |
k |
The number of smallest elements sought. |
p |
The number of smallest elements sought, specified as proportion of the length of |
Details
These functions are used internally in the determination of nearest neighbours; the user need not call any of these functions directly. Rather, the choice is specified via the arguments k
and p
.
Value
Either the smallest values themselves or, for the which.* functions, their positions in the vector.
Author(s)
Mohit Dayal
See Also
get.NN
Examples
x <- rnorm(10)
least.k(x, 3)
least.p(x, 0.3)
which.least.k(x, 3)
which.least.p(x, 0.3)