closest: Find closest point(s) in a design or object.

Description Usage Arguments Details Value Examples

Description

Find closest point(s) in a design matrix or object.

Usage

1
closest(X, XNew, ...)

Arguments

X

A matrix containing design points as rows or a "Grid" object.

XNew

A vector or matrix containing one or several 'new' design points.

...

Other arguments for methods.

Details

When X has class "Grid" weighting the factors has no impact on the (or a) closest point since for each factor there is normally one (and possibly two) level value(s) which minimises the distance to the corresponding value in the given new point (row) of XNew.

Value

A list with elements

index

Integer vector with length equal to the number of 'new' points. Contains the index of the closest point in X.

value

Matrix with one row for each 'new' design point containing the closest point as found in X.

dist

Numeric vector with length equal to the number of 'new' points. Contains the minimal distances.

Examples

1
2
3
4
5
6
## levels at 0, 0.2, 0.4, 0.6, 0.8, 1.0
g <- Grid(nlevels = c("x" = 6, "y" = 6, "z" = 6))
XNew <- c(0.51, 0.61, 0.23)
closest(X = g, XNew = XNew)
X <- as.matrix(g)
closest(X = X, XNew = XNew)

smint documentation built on April 14, 2017, 1:49 p.m.