Learn R Programming

GeNetIt (version 0.1-6)

adj_matrix: Binary adjacency matrix

Description

Creates a binary matrix of adjacencies based on from-to graph relationships (joins)

Usage

adj_matrix(i, j = NULL)

Value

A binary matrix

Arguments

i

a vector or, if j = NULL a data.frame with two columns indicating from-to relationships (joins)

j

If specified, i must be a vector of same length and the i,j vectors must represent joins

Author

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

Examples

Run this code
 library(sf)
   data(ralu.site, package="GeNetIt")
   
 p <- as(ralu.site, "sf")
 g <- knn.graph(p[c(1,5,8,10,20,31),])
   plot(st_geometry(g))

 ( ind <- sf::st_drop_geometry(g[,1:2])[1:10,] ) 

 adj_matrix(ind)

 adj_matrix(g$i[1:10], g$j[1:10])

Run the code above in your browser using DataLab