| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/labels.R |
| 3 |
\name{labels<-} |
| 4 |
\alias{labels<-} |
| 5 |
\alias{labels<-.default} |
| 6 |
\alias{labels<-.dendrogram} |
| 7 |
\alias{labels.hclust} |
| 8 |
\alias{labels<-.hclust} |
| 9 |
\alias{labels.phylo} |
| 10 |
\alias{labels<-.phylo} |
| 11 |
\title{"label" assignment operator} |
| 12 |
\source{ |
| 13 |
The functions here are based on code by Gavin and kohske from |
| 14 |
(adopted to dendrogram by Tal Galili): |
| 15 |
\url{https://stackoverflow.com/questions/4614223/how-to-have-the-following-work-labelsx-some-value-r-question} |
| 16 |
Also with some ideas from Gregory Jefferis's dendroextras package. |
| 17 |
} |
| 18 |
\usage{ |
| 19 |
labels(object, ...) <- value |
| 20 |
|
| 21 |
\method{labels}{default}(object, ...) <- value |
| 22 |
|
| 23 |
\method{labels}{dendrogram}(object, ...) <- value |
| 24 |
|
| 25 |
\method{labels}{hclust}(object, order = TRUE, ...) |
| 26 |
|
| 27 |
\method{labels}{hclust}(object, ...) <- value |
| 28 |
|
| 29 |
\method{labels}{phylo}(object, ...) |
| 30 |
|
| 31 |
\method{labels}{phylo}(object, ...) <- value |
| 32 |
} |
| 33 |
\arguments{ |
| 34 |
\item{object}{a variable name (possibly quoted) who's label are to be updated} |
| 35 |
|
| 36 |
\item{...}{parameters passed (not currently in use)} |
| 37 |
|
| 38 |
\item{value}{a value to be assigned to object's label} |
| 39 |
|
| 40 |
\item{order}{default is FALSE. Only relevant for extracting labels from an |
| 41 |
\link{hclust} object (with labels.hclust). Setting order=TRUE will return |
| 42 |
labels in their order in the dendrogram, instead of the riginal labels order |
| 43 |
retained from object$labels - which ususally corresponding to |
| 44 |
the row or column names of the \link{dist} object provided to |
| 45 |
the \link{hclust} function.} |
| 46 |
} |
| 47 |
\value{ |
| 48 |
The updated object |
| 49 |
} |
| 50 |
\description{ |
| 51 |
"label" assignment operator for vectors, dendrogram, and hclust classes. |
| 52 |
} |
| 53 |
\details{ |
| 54 |
################### |
| 55 |
} |
| 56 |
\examples{ |
| 57 |
x <- 1:3 |
| 58 |
labels(x) |
| 59 |
labels(x) <- letters[1:3] |
| 60 |
labels(x) # [1] "a" "b" "c" |
| 61 |
x |
| 62 |
# a b c |
| 63 |
# 1 2 3 |
| 64 |
|
| 65 |
|
| 66 |
# get("labels<-") |
| 67 |
|
| 68 |
################ |
| 69 |
# Example for using the assignment with dendrogram and hclust objects: |
| 70 |
hc <- hclust(dist(USArrests[1:3, ]), "ave") |
| 71 |
dend <- as.dendrogram(hc) |
| 72 |
|
| 73 |
labels(hc) # "Arizona" "Alabama" "Alaska" |
| 74 |
labels(hc) <- letters[1:3] |
| 75 |
labels(hc) # "a" "b" "c" |
| 76 |
labels(dend) # "Arizona" "Alabama" "Alaska" |
| 77 |
labels(dend) <- letters[1:3] |
| 78 |
labels(dend) # "a" "b" "c" |
| 79 |
suppressWarnings(labels(dend) <- LETTERS[1:2]) # will produce a warning |
| 80 |
labels(dend) # "A" "B" "A" |
| 81 |
labels(dend) <- LETTERS[4:6] # will replace the labels correctly |
| 82 |
# (the fact the tree had duplicate labels will not cause a problem) |
| 83 |
labels(dend) # "D" "E" "F" |
| 84 |
} |
| 85 |
\seealso{ |
| 86 |
\code{\link{labels}} |
| 87 |
} |
| 88 |
\author{ |
| 89 |
Gavin Simpson, Tal Galili |
| 90 |
(with some ideas from Gregory Jefferis's dendroextras package) |
| 91 |
} |