chooseCN
is a simple interface to build a connection
network (CN) from xy coordinates. The user chooses from 6 types of graph and
one additional weighting scheme. chooseCN
calls functions from
appropriate packages, handles non-unique coordinates and returns a
connection network either with classe nb
or listw
. For graph
types 1-4, duplicated locations are not accepted and will issue an error.
chooseCN(xy, ask = TRUE, type = NULL, result.type = "nb", d1 = NULL, d2 = NULL, k = NULL, a = NULL, dmin = NULL, plot.nb = TRUE, edit.nb = FALSE)
type
is provided.spdep
package. See
details.type=5.
type=5
. Can also be a character: "dmin" for the minimum distance so
that each site has at least one connection, or "dmax" to have all sites
connected (despite the later has no sense).type=6
.type=7
.type=7
.nb
or
listw
. The xy coordinates are passed as attribute to the created
object.
The last option (type=7) is not a true neighbouring graph: all sites are
neighbours, but the spatial weights are directly proportional to the
inversed spatial distances. Also not that in this case, the output of the
function is always a listw
object, even if nb
was
requested.
The choice of the connection network has been discuted on the adegenet forum. Please search the archives from adegenet website (section 'contact') using 'graph' as keyword.
if(require("ade4", quietly = TRUE)){
data(mafragh)
par(mfrow=c(2,2))
cn1 <- chooseCN(mafragh$xy,ask=FALSE,type=1)
cn2 <- chooseCN(mafragh$xy,ask=FALSE,type=2)
cn3 <- chooseCN(mafragh$xy,ask=FALSE,type=3)
cn4 <- chooseCN(mafragh$xy,ask=FALSE,type=4)
}
Run the code above in your browser using DataLab