This function computes the Euclidean distance from each point
in a three-dimensional
point pattern to its nearest neighbour (the nearest other
point of the pattern). If k is specified, it computes the
distance to the kth nearest neighbour.
The function nndist is generic; this function
nndist.pp3 is the method for the class "pp3".
The argument k may be a single integer, or an integer vector.
If it is a vector, then the \(k\)th nearest neighbour distances are
computed for each value of \(k\) specified in the vector.
If there is only one point (if x has length 1),
then a nearest neighbour distance of Inf is returned.
If there are no points (if x has length zero)
a numeric vector of length zero is returned.
If the argument by is given, it should be a factor,
of length equal to the number of points in X.
This factor effectively partitions X into subsets,
each subset associated with one of the levels of X.
The algorithm will then compute, for each point of X,
the distance to the nearest neighbour in each subset.
To identify which point is the nearest neighbour of a given point,
use nnwhich.
To use the nearest neighbour distances for statistical inference,
it is often advisable to use the edge-corrected empirical distribution,
computed by G3est.
To find the nearest neighbour distances from one point pattern
to another point pattern, use nncross.