least.k: Functions to find the few smallest elements in a vector.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/knn_header.R

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

1
2
3
4
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.

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

1
2
3
4
5
x <- rnorm(10)
least.k(x, 3)
least.p(x, 0.3)
which.least.k(x, 3)
which.least.p(x, 0.3)

Example output

Warning message:
no DISPLAY variable so Tk is not available 
[1] -0.3374462 -0.3147502 -0.2533106
[1] -0.3374462 -0.3147502 -0.2533106
NULL
NULL

MuViCP documentation built on May 1, 2019, 7:56 p.m.