MuViCP (version 1.3.2)

least.k: 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 x.

Value

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.

See Also

get.NN

Examples

Run this code
x <- rnorm(10)
least.k(x, 3)
least.p(x, 0.3)
which.least.k(x, 3)
which.least.p(x, 0.3)

Run the code above in your browser using DataLab