Learn R Programming

labdsv (version 1.2-2)

vardist: Variable Pairwise Difference

Description

Calculates a matrix of pair-wise differences between value for a particular numeric variable for a dataset.

Usage

vardist(x)

Arguments

x
a vector of numeric values

Value

  • an object of class dist

Details

Calculates the absolute value of the difference between all possible values in a vector, producing a matrix of differences with as many rows and columns as the length of the vector

References

http://ecology.msu.montana.edu/labdsv/R

Examples

Run this code
data(bryceveg) # returns a vegetation data.frame called bryceveg
    data(brycesite) # returns an environmental data.frame called brycesite
    dis.bc <- dsvdis(bryceveg,'bray/curtis') # returns a Bray/Curtis dissimilarity matrix
    dis.elev <- vardist(brycesite$elev) # matrix of pair-wide differences in elevation
    cor(as.vector(dis.bc),as.vector(dis.elev))

Run the code above in your browser using DataLab