Description Usage Arguments Value See Also Examples
Computes hierarchical clustering (hclust, agnes, diana) and cut the tree into k clusters. It also accepts correlation based distance measure methods such as "pearson", "spearman" and "kendall".
1 2 3 4 5 6 7 8 9 10 11 |
x |
a numeric matrix, numeric data frame or a dissimilarity matrix. |
k |
the number of clusters to be generated. |
isdiss |
logical value specifying wether x is a dissimilarity matrix. |
hc_func |
the hierarchical clustering function to be used. Default value is "hclust". Possible values is one of "hclust", "agnes", "diana". Abbreviation is allowed. |
hc_method |
the agglomeration method to be used (?hclust) for hclust() and agnes(): "ward.D", "ward.D2", "single", "complete", "average", ... |
hc_metric |
character string specifying the metric to be used for calculating dissimilarities between observations. Allowed values are those accepted by the function dist() [including "euclidean", "manhattan", "maximum", "canberra", "binary", "minkowski"] and correlation based distance measures ["pearson", "spearman" or "kendall"]. |
stand |
logical value; default is FALSE. If TRUE, then the data will be standardized using the function scale(). Measurements are standardized for each variable (column), by subtracting the variable's mean value and dividing by the variable's standard deviation. |
graph |
logical value. If TRUE, the dendrogram is displayed. |
... |
not used. |
an object of class "hcut" containing the result of the standard function used (read the documentation of hclust, agnes, diana).
It includes also:
cluster: the cluster assignement of observations after cutting the tree
nbclust: the number of clusters
silinfo: the silhouette information of observations (if k > 1)
size: the size of clusters
data: a matrix containing the original or the standardized data (if stand = TRUE)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | data(USArrests)
# Compute hierarchical clustering and cut into 4 clusters
res <- hcut(USArrests, k = 4, stand = TRUE)
# Cluster assignements of observations
res$cluster
# Size of clusters
res$size
# Visualize the dendrogram
fviz_dend(res, rect = TRUE)
# Visualize the silhouette
fviz_silhouette(res)
# Visualize clusters as scatter plots
fviz_cluster(res)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.