clustermap()
performs a classification of the sites from the variables called
in names.var
and computes a bar plot of the clusters calculated.
Classification methods come from hclust()
(hierarchical cluster analysis) and kmeans()
(k-means clustering) and number of class is chosen with clustnum
.
clustermap(sp.obj, names.var, clustnum, method=c("kmeans","hclust"), type=NULL,
centers=NULL, scale=FALSE, names.arg="", names.attr=names(sp.obj), criteria=NULL,
carte=NULL, identify=FALSE, cex.lab=0.8, pch=16, col="lightblue3",
xlab="Cluster", ylab="Number", axes=FALSE, lablong="", lablat="")
save results
button,
a list is created as a global variable in last.select
object. obs
, a vector of integer,
corresponds to the number of spatial units selected just before leaving the Tk window, vectclass
,
vector of integer, corresponds to the number of cluster attributed to each spatial unit.
Murtagh, F (1985). Multidimensional Clustering Algorithms.
Hartigan, J. A. and Wong, M. A. (1979). A K-means clustering algorithm. Applied Statistics 28, 100-108
Roger S.Bivand, Edzer J.Pebesma, Virgilio Gomez-Rubio (2009), Applied Spatial Data Analysis with R, Springer.
barmap
, pcamap
#####
# data columbus
require("maptools")
example(columbus)
# a basic example using the kmeans method
clustermap(columbus, c("HOVAL","INC","CRIME","OPEN","PLUMB","DISCBD"), 3,
criteria=(columbus@data$CP==1), identify=TRUE, cex.lab=0.7)
# example using the hclust method
clustermap(columbus,c(7:12), 3, method="hclust",
criteria=(columbus@data$CP==1),col=colors()[20:22],identify=TRUE,
cex.lab=0.7, names.arg=c("Group 1","Group 2","Group 3"), xlab="Cluster")
Run the code above in your browser using DataLab