Learn R Programming

labdsv (version 2.1-0)

neighbors: Neighbors

Description

Calculates the nearest neighbors in a distance/dissimilarity matrix

Usage

neighbors(dis,numnbr)

Value

Returns a data.frame with sample units as rows and neighbors as columns, listed in order of proximity to the sample unit.

Arguments

dis

an object of class ‘dist’ such as returned by dist, vegdist or dsvdis

numnbr

the number (order) of neighbors to return

Author

David W. Roberts droberts@montana.edu

Details

For each sample unit in a dissimilarity matrix finds the ‘numnbr’ nearest neighbors and returns them in order.

Examples

Run this code
data(bryceveg) # returns a data.frame called veg
dis.bc <- dsvdis(bryceveg,'bray/curtis')
neighbors(dis.bc,5)

Run the code above in your browser using DataLab