Debian Codegraph @

man/cutree_1h.dendrogram.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/cutree.dendrogram.R
3 \name{cutree_1h.dendrogram}
4 \alias{cutree_1h.dendrogram}
5 \title{cutree for dendrogram (by 1 height only!)}
6 \usage{
7 cutree_1h.dendrogram(
8 dend,
9 h,
10 order_clusters_as_data = TRUE,
11 use_labels_not_values = TRUE,
12 warn = dendextend_options("warn"),
13 ...
14 )
15 }
16 \arguments{
17 \item{dend}{a dendrogram object}
18
19 \item{h}{numeric scalar (NOT a vector) with a height where the dend should be cut.}
20
21 \item{order_clusters_as_data}{logical, defaults to TRUE. There are two ways by which
22 to order the clusters: 1) By the order of the original data. 2) by the order of the
23 labels in the dendrogram. In order to be consistent with \link[stats]{cutree}, this is set
24 to TRUE.}
25
26 \item{use_labels_not_values}{logical, defaults to TRUE. If the actual labels of the
27 clusters do not matter - and we want to gain speed (say, 10 times faster) -
28 then use FALSE (gives the "leaves order" instead of their labels.).}
29
30 \item{warn}{logical (default from dendextend_options("warn") is FALSE).
31 Set if warning are to be issued, it is safer to keep this at TRUE,
32 but for keeping the noise down, the default is FALSE.}
33
34 \item{...}{(not currently in use)}
35 }
36 \value{
37 \code{cutree_1h.dendrogram} returns an integer vector with group memberships
38 }
39 \description{
40 Cuts a dendrogram tree into several groups
41 by specifying the desired cut height (only a single height!).
42 }
43 \examples{
44 hc <- hclust(dist(USArrests[c(1, 6, 13, 20, 23), ]), "ave")
45 dend <- as.dendrogram(hc)
46 cutree(hc, h = 50) # on hclust
47 cutree_1h.dendrogram(dend, h = 50) # on a dendrogram
48
49 labels(dend)
50
51 # the default (ordered by original data's order)
52 cutree_1h.dendrogram(dend, h = 50, order_clusters_as_data = TRUE)
53
54 # A different order of labels - order by their order in the tree
55 cutree_1h.dendrogram(dend, h = 50, order_clusters_as_data = FALSE)
56
57
58 # make it faster
59 \dontrun{
60 library(microbenchmark)
61 microbenchmark(
62 cutree_1h.dendrogram(dend, h = 50),
63 cutree_1h.dendrogram(dend, h = 50, use_labels_not_values = FALSE)
64 )
65 # 0.8 vs 0.6 sec - for 100 runs
66 }
67
68 }
69 \seealso{
70 \code{\link{hclust}}, \code{\link{cutree}}
71 }
72 \author{
73 Tal Galili
74 }