pick.min.max {nnspat}R Documentation

Smallest and Largest Distances in a Distance Matrix

Description

This function finds and returns the k smallest and k largest distances in a distance matrix or distance object, and also provides pairs of objects these distances correspond to. The code is adapted from http://people.stat.sc.edu/Hitchcock/chapter1_R_examples.txt.

Usage

pick.min.max(ds, k = 1)

Arguments

ds

A distance matrix or a distance object

k

A positive integer representing the number of (min and max) distances to be presented, default is k=1

Value

A list with the elements

min.dis

The k smallest distances in ds

ind.min.dis

The indices (i.e., row numbers) of the k pairs of object which has the k smallest distances in ds

max.dis

The k largest distances in ds

ind.max.dis

The indices (i.e., row numbers) of the k pairs of object which has the k largest distances in ds

Author(s)

Elvan Ceyhan

See Also

dist, ipd.mat, and ipd.mat.euc

Examples

n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
pick.min.max(ipd)
#or
pick.min.max(dist(Y))

pick.min.max(ipd,2)


[Package nnspat version 0.1.2 Index]