| daisy {cluster} | R Documentation |
Compute all the pairwise dissimilarities (distances) between observations in the dataset. The original variables may be of mixed types.
daisy(x, metric = c("euclidean","manhattan"), stand = FALSE, type = list())
x |
numeric matrix or data frame. Dissimilarities will be computed
between the rows of x. Columns of mode numeric
(i.e. all columns when x is a matrix) will be recognized as
interval scaled variables, columns of class factor will be
recognized as nominal variables, and columns of class ordered
will be recognized as ordinal variables. Other variable types
should be specified with the type argument. Missing values
(NAs) are allowed.
|
metric |
character string specifying the metric to be used.
The currently available options are "euclidean" (the default)
and "manhattan".Euclidean distances are root sum-of-squares of differences, and manhattan distances are the sum of absolute differences. If not all columns of x art face="Courier New,Courier" color="#666666">R,
are recycled to have length the number of observations.
If col.p has more than one value, using color = TRUE can
be confusing because of a mix of point and ellipse colors.
References
Pison, G., Struyf, A. and Rousseeuw, P.J. (1999)
Displaying a Clustering with CLUSPLOT,
Computational Statistics and Data Analysis, 30, 381–392. Kaufman, L. and Rousseeuw, P.J. (1990). Finding Groups in Data: An Introduction to Cluster Analysis. Wiley, New York. Struyf, A., Hubert, M. and Rousseeuw, P.J. (1997). Integrating Robust Clustering Techniques in S-PLUS, Computational Statistics and Data Analysis, 26, 17-37. See Also
Examples
## plotting votes.diss(dissimilarity) in a bivariate plot and
## partitioning into 2 clusters
data(votes.repub)
votes.diss <- daisy(votes.repub)
votes.clus <- pam(votes.diss, 2, diss = TRUE)$clustering
clusplot(votes.diss, votes.clus, diss = TRUE, shade = TRUE)
clusplot(votes.diss, votes.clus, diss = TRUE,
col.p = votes.clus, labels = 4)# color points and label ellipses
clusplot(votes.diss, votes.clus, diss = TRUE, span = FALSE)# simple ellipses
if(interactive()) { # uses identify() *interactively* :
clusplot(votes.diss, votes.clus, diss = TRUE, shade = TRUE, labels = 1)
clusplot(votes.diss, votes.clus, diss = TRUE, labels = 5)# ident. only points
}
## plotting iris (data frame) in a 2-dimensional plot and partitioning
## into 3 clusters.
data(iris)
iris.x <- iris[, 1:4]
cl3 <- pam(iris.x, 3)$clustering
op <- par(mfrow= c(2,2))
clusplot(iris.x, cl3, color = TRUE)
U <- par("usr")
## zoom in :
rect(0,-1, 2,1, border = "orange", lwd=2)
clusplot(iris.x, cl3, color = TRUE, xlim = c(0,2), ylim = c(-1,1))
box(col="orange",lwd=2); mtext("sub region", font = 4, cex = 2)
## or zoom out :
clusplot(iris.x, cl3, color = TRUE, xlim = c(-4,4), ylim = c(-4,4))
mtext("`super' region", font = 4, cex = 2)
rect(U[1],U[3], U[2],U[4], lwd=2, lty = 3)
# reset graphics
par(op)
[Package cluster version 1.11.2 Index]
|