| NNdist {nnspat} | R Documentation | 
Distances between subjects and their NNs
Description
Returns the distances between subjects and their NNs. 
The output is an n \times 2 matrix 
where n is the data size
and first column is the subject index and 
second column contains the corresponding distances to NN subjects.
The argument is.ipd is a logical argument 
(default=TRUE) to determine the structure of the argument x.
If TRUE, x is taken to be 
the inter-point distance (IPD) matrix, 
and if FALSE, x is taken to be the data set
with rows representing the data points.
Usage
NNdist(x, is.ipd = TRUE, ...)
Arguments
| x | The IPD matrix (if  | 
| is.ipd | A logical parameter (default= | 
| ... | are for further arguments, 
such as  | 
Value
Returns an n \times 2 matrix where n is data size 
(i.e., number of subjects) and first column is the subject
index and second column is the NN distances.
Author(s)
Elvan Ceyhan
See Also
kthNNdist, kNNdist, 
and NNdist2cl
Examples
#3D data points
n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
NNdist(ipd)
NNdist(Y,is.ipd = FALSE)
NNdist(Y,is.ipd = FALSE,method="max")
#1D data points
X<-as.matrix(runif(5)) # need to be entered as a matrix with one column
#(i.e., a column vector), hence X<-runif(5) would not work
ipd<-ipd.mat(X)
NNdist(ipd)
NNdist(X,is.ipd = FALSE)