| chooseCN {adegenet} | R Documentation |
The function chooseCN is a simple interface to
build a connection network (CN) from xy coordinates. The user chooses
from 6 kind of graphes. chooseCN calls functions from
appropriate packages, handles non-unique coordinates and returns a
connection network either with classe nb or listw.
chooseCN(xy, ask = TRUE, type = 1, result.type = "nb", d1 = NULL,
d2 = NULL, k = NULL, plot.nb = TRUE, edit.nb = FALSE)
xy |
an matrix or data.frame with two columns for x and y coordinates. |
ask |
a logical stating whether graph should be chosen interactively (TRUE,default) or not (FALSE). |
type |
an integer giving the type of graph (see details). Used if
ask=FALSE |
result.type |
a character giving the class of the returned
object. Either "nb" (default) or "listw", both from spdep
package. |
d1 |
the minimum distance between any two neighbours. Used if
type=5. |
d2 |
the maximum distance between any two neighbours. Used if
type=5. |
k |
the number of neighbours per point. Used if
type=6. |
plot.nb |
a logical stating whether the resulting graph should be plotted (TRUE, default) or not (FALSE). |
edit.nb |
a logical stating whether the resulting graph should be edited manually for corrections (TRUE) or not (FALSE, default). |
There are 6 kinds of graphs proposed:
Delaunay triangulation (type 1)
Gabriel graph (type 2)
Relative neighbours (type 3)
Minimum spanning tree (type 4)
Neighbourhood by distance (type 5)
K nearests neighbours (type 6)
Returns a connection network having the class nb or listw.
Thibaut Jombart jombart@biomserv.univ-lyon1.fr
data(nancycats)
if(require(spdep) & require(ade4)){
par(mfrow=c(2,2))
cn1 <- chooseCN(nancycats$xy,ask=FALSE,type=1)
cn2 <- chooseCN(nancycats$xy,ask=FALSE,type=2)
cn3 <- chooseCN(nancycats$xy,ask=FALSE,type=3)
cn4 <- chooseCN(nancycats$xy,ask=FALSE,type=4)
par(mfrow=c(1,1))
}