Title: | R port of redcap |
---|---|
Description: | R port of redcap (Regionalization with dynamically constrained agglomerative clustering and partitioning). |
Authors: | Mark Padgham [aut, cre] |
Maintainer: | Mark Padgham <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0.006 |
Built: | 2024-10-10 04:15:52 UTC |
Source: | https://github.com/mpadge/spatialcluster |
Plot dendrogram of merges for scl
object with method = "full"
.
plot_merges(x, root_tree = FALSE)
plot_merges(x, root_tree = FALSE)
x |
Object of class |
root_tree |
If |
Nothing (generates plot)
Other plot_fns:
plot.scl()
plot.scl
## S3 method for class 'scl' plot(x, ..., hull_alpha = 1)
## S3 method for class 'scl' plot(x, ..., hull_alpha = 1)
x |
object to be plotted |
... |
ignored here |
hull_alpha |
alpha value of (non-)convex hulls, with default generating a convex hull, and smaller values generating concave hulls. (See ?alphashape::ashape for details). |
Other plot_fns:
plot_merges()
set.seed (1) n <- 100 xy <- matrix (runif (2 * n), ncol = 2) dmat <- matrix (runif (n ^ 2), ncol = n) scl <- scl_redcap (xy, dmat, ncl = 4) plot (scl) # Connect clusters according to highest (\code{shortest = FALSE}) values of # \code{dmat}: scl <- scl_redcap (xy, dmat, ncl = 4, shortest = FALSE, full_order = FALSE) plot (scl)
set.seed (1) n <- 100 xy <- matrix (runif (2 * n), ncol = 2) dmat <- matrix (runif (n ^ 2), ncol = n) scl <- scl_redcap (xy, dmat, ncl = 4) plot (scl) # Connect clusters according to highest (\code{shortest = FALSE}) values of # \code{dmat}: scl <- scl_redcap (xy, dmat, ncl = 4, shortest = FALSE, full_order = FALSE) plot (scl)
Full spatially-constrained clustering.
scl_full(xy, dmat, ncl, linkage = "single", shortest = TRUE, nnbs = 6L)
scl_full(xy, dmat, ncl, linkage = "single", shortest = TRUE, nnbs = 6L)
xy |
Rectangular structure (matrix, data.frame, tibble), containing coordinates of points to be clustered. |
dmat |
Square structure (matrix, data.frame, tibble) containing
distances or equivalent metrics between all points in |
ncl |
Desired number of clusters. See description of 'ncl_iterate' parameter for conditions under which actual number may be less than this value. |
linkage |
Either |
shortest |
If |
nnbs |
Number of nearest neighbours to be used in calculating clustering
trees. Triangulation will be used if |
Other clustering_fns:
scl_recluster()
,
scl_redcap()
n <- 100 xy <- matrix (runif (2 * n), ncol = 2) dmat <- matrix (runif (n ^ 2), ncol = n) scl <- scl_full (xy, dmat, ncl = 4)
n <- 100 xy <- matrix (runif (2 * n), ncol = 2) dmat <- matrix (runif (n ^ 2), ncol = n) scl <- scl_full (xy, dmat, ncl = 4)
Re-cut a spatial cluster tree (scl
) at a different number of clusters.
scl_recluster(scl, ncl, shortest = TRUE, quiet = FALSE)
scl_recluster(scl, ncl, shortest = TRUE, quiet = FALSE)
scl |
An |
ncl |
Desired number of clusters. See description of 'ncl_iterate' parameter for conditions under which actual number may be less than this value. |
shortest |
If |
quiet |
If 'FALSE' (default), display progress information on screen. |
Modified scl
object in which tree
is re-cut into
ncl
clusters.
Other clustering_fns:
scl_full()
,
scl_redcap()
n <- 100 xy <- matrix (runif (2 * n), ncol = 2) dmat <- matrix (runif (n ^ 2), ncol = n) scl <- scl_redcap (xy, dmat, ncl = 4) plot (scl) scl <- scl_recluster (scl, ncl = 5) plot (scl)
n <- 100 xy <- matrix (runif (2 * n), ncol = 2) dmat <- matrix (runif (n ^ 2), ncol = n) scl <- scl_redcap (xy, dmat, ncl = 4) plot (scl) scl <- scl_recluster (scl, ncl = 5) plot (scl)
Cluster spatial data with REDCAP (REgionalization with Dynamically Constrained Agglomerative clustering and Partitioning) routines.
scl_redcap( xy, dmat, ncl, full_order = TRUE, linkage = "single", shortest = TRUE, nnbs = 6L, iterate_ncl = FALSE, quiet = FALSE )
scl_redcap( xy, dmat, ncl, full_order = TRUE, linkage = "single", shortest = TRUE, nnbs = 6L, iterate_ncl = FALSE, quiet = FALSE )
xy |
Rectangular structure (matrix, data.frame, tibble), containing coordinates of points to be clustered. |
dmat |
Square structure (matrix, data.frame, tibble) containing
distances or equivalent metrics between all points in |
ncl |
Desired number of clusters. See description of 'ncl_iterate' parameter for conditions under which actual number may be less than this value. |
full_order |
If |
linkage |
One of |
shortest |
If |
nnbs |
Number of nearest neighbours to be used in calculating clustering
trees. Triangulation will be used if |
iterate_ncl |
Actual numbers of clusters found may be less than the specified value of 'ncl', because clusters formed from < 3 edges are removed. If 'iterate_ncl = FALSE' (the default), the value is returned with whatever number of actual clusters is found. Setting this parameter to 'TRUE' forces the algorithm to iterate until the exact number of clusters has been found. For large data sets, this may result in considerable longer calculation times. |
quiet |
If 'FALSE' (default), display progress information on screen. |
A object of class scl
with tree
containing the
clustering scheme, and xy
the original coordinate data of the
clustered points. An additional component, tree_rest
, enables the tree
to be re-cut to a different number of clusters via scl_recluster,
rather than calculating clusters anew.
Please refer to the original REDCAP paper ('Regionalization with
dynamically constrained agglomerative clustering and partitioning (REDCAP)',
by D. Guo (2008), Int.J.Geo.Inf.Sci 22:801-823) for details of the
full_order
and linkage
parameters. This paper clearly
demonstrates the general inferiority of spanning trees constructed from
first-order relationships. It is therefore strongly recommended that the
default full_order = TRUE
be used at all times.
Other clustering_fns:
scl_full()
,
scl_recluster()
n <- 100 xy <- matrix (runif (2 * n), ncol = 2) dmat <- matrix (runif (n ^ 2), ncol = n) scl <- scl_redcap (xy, dmat, ncl = 4) # Those clusters will by default be constructed by connecting edges with the # lowest (\code{shortest}) values of \code{dmat}, and will differ from scl <- scl_redcap (xy, dmat, ncl = 4, shortest = FALSE) # using 'full_order = FALSE' constructs clusters from first-order # relationships only; not recommended, but possible nevertheless: scl <- scl_redcap (xy, dmat, ncl = 4, full_order = FALSE)
n <- 100 xy <- matrix (runif (2 * n), ncol = 2) dmat <- matrix (runif (n ^ 2), ncol = n) scl <- scl_redcap (xy, dmat, ncl = 4) # Those clusters will by default be constructed by connecting edges with the # lowest (\code{shortest}) values of \code{dmat}, and will differ from scl <- scl_redcap (xy, dmat, ncl = 4, shortest = FALSE) # using 'full_order = FALSE' constructs clusters from first-order # relationships only; not recommended, but possible nevertheless: scl <- scl_redcap (xy, dmat, ncl = 4, full_order = FALSE)
R port of redcap (Regionalization with dynamically constrained agglomerative clustering and partitioning).