| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/labels.R |
| 3 |
\name{set_labels} |
| 4 |
\alias{set_labels} |
| 5 |
\alias{place_labels} |
| 6 |
\title{Set/place new labels in a dendrogram} |
| 7 |
\usage{ |
| 8 |
set_labels(dend, labels, ...) |
| 9 |
} |
| 10 |
\arguments{ |
| 11 |
\item{dend}{a \link{dendrogram} object} |
| 12 |
|
| 13 |
\item{labels}{A vector of values to insert in the labels of a dendrogram.} |
| 14 |
|
| 15 |
\item{...}{Currently ignored.} |
| 16 |
} |
| 17 |
\value{ |
| 18 |
The updated \link{dendrogram} object |
| 19 |
} |
| 20 |
\description{ |
| 21 |
Convenience functions for updating the labels of a dendrogram. |
| 22 |
set_labels and place_labels differs in their assumption about the order of the labels. |
| 23 |
* set_labels assumes the labels are in the same order as that of the labels in the dendrogram. |
| 24 |
* place_labels assumes the labels has the same order as that of the items in the original data matrix. |
| 25 |
This is useful for renaming labels based on some other columns in the data matrix. |
| 26 |
} |
| 27 |
\examples{ |
| 28 |
|
| 29 |
ss <- c( |
| 30 |
50, 114, 17, 102, 76, 10, 107, 84, 31, 37, 49, 106, 44, 119, |
| 31 |
104, 145, 67, 85, 12, 77, 22, 136, 38, 135, 70 |
| 32 |
) |
| 33 |
|
| 34 |
small_iris <- iris[ss, ] |
| 35 |
|
| 36 |
small_iris[, -5] \%>\% |
| 37 |
dist() \%>\% |
| 38 |
hclust(method = "complete") \%>\% |
| 39 |
as.dendrogram() \%>\% |
| 40 |
color_branches(k = 3) \%>\% |
| 41 |
color_labels(k = 3) \%>\% |
| 42 |
plot() |
| 43 |
|
| 44 |
# example for using place_labels |
| 45 |
small_iris[, -5] \%>\% |
| 46 |
dist() \%>\% |
| 47 |
hclust(method = "complete") \%>\% |
| 48 |
as.dendrogram() \%>\% |
| 49 |
color_branches(k = 3) \%>\% |
| 50 |
color_labels(k = 3) \%>\% |
| 51 |
place_labels(paste(small_iris$Species, 1:25, sep = "_")) \%>\% |
| 52 |
plot() |
| 53 |
|
| 54 |
# example for using set_labels |
| 55 |
small_iris[, -5] \%>\% |
| 56 |
dist() \%>\% |
| 57 |
hclust(method = "complete") \%>\% |
| 58 |
as.dendrogram() \%>\% |
| 59 |
color_branches(k = 3) \%>\% |
| 60 |
color_labels(k = 3) \%>\% |
| 61 |
set_labels(1:25) \%>\% |
| 62 |
plot() |
| 63 |
} |
| 64 |
\seealso{ |
| 65 |
\code{\link{labels}}, \code{\link{set}} |
| 66 |
} |
| 67 |
\author{ |
| 68 |
Tal Galili, Garrett Grolemund |
| 69 |
} |