GeNetIt (version 0.1-4)

dmatrix.df: Distance matrix to data.frame

Description

Coerces distance matrix to a data.frame object

Usage

dmatrix.df(x, rm.diag = TRUE)

Value

data.frame object representing to and from values

Arguments

x

Symmetrical distance matrix

rm.diag

(TRUE/FALSE) remove matrix diagonal, self values.

Author

Jeffrey S. Evans <jeffrey_evans@tnc.org> and Melanie Murphy <melanie.murphy@uwyo.edu>

Examples

Run this code
  library(sp)
  pts <- cbind( x=runif(15, 480933, 504250), y=runif(15, 4479433, 4535122))
    pts <- SpatialPointsDataFrame(pts, 
             data.frame(ID=paste("ob",1:nrow(pts),sep="")))
  
  # Create distance matrix  
  dm <- spDists(pts, pts)  
    colnames(dm) <- pts@data[,"ID"] 
    rownames(dm) <- pts@data[,"ID"]
  
  # Coerce to data.frame with TO and FROM ID's and associated distance
  dm.df <- dmatrix.df(dm)
    head(dm.df)

Run the code above in your browser using DataCamp Workspace