Skip to content

Matrix problem to extract animal associations

2 messages · Ross Dwyer, ilai

#
set.seed(1)
(DFid <- data.frame(
x = sample(1:20,10),
y = sample(1:20,10),
IDs = sapply(1:10,function(i) paste("ID",i,sep=""))))

require(spdep)
coordinates(DFid) <- ~x+y
coords <- coordinates(DFid)
dnn4 <- dnearneigh(DFid,0,4)
 summary(dnn4)
 plot(DFid)
 plot(dnn4,coords,add=T,col=2)
 nb2mat(dnn4, zero.policy=TRUE)

This just one option from the multitude of spatial packages.

HTH
On Sun, Feb 26, 2012 at 4:55 PM, Ross Dwyer <ross.dwyer at uq.edu.au> wrote: