subset.dendrogram | R Documentation |
Subsets dendrogram objects based on leaf labels. Subsetting can either be by leaves to keep, or leaves to remove.
NOTE: This man page is specifically for subset.dendogram
, see ?base::subset
for the generic subset
function defined for vectors, matrices, and data frames.
## S3 method for class 'dendrogram'
subset(x, subset, invert=FALSE, ...)
x |
An object of class |
subset |
Character; A vector of labels to keep (see |
invert |
Logical; If |
... |
Additional arguments for consistency with generic. |
An object of class 'dendrogram'
corresponding to the subset of the tree.
If none of the labels specified in the subset
argument appear in the tree (or if all do when invert=TRUE
), a warning is thrown and an empty object of class 'dendrogram'
is returned.
Aidan Lakshman ahl27@pitt.edu
subset
d <- as.dendrogram(hclust(dist(USArrests), "ave"))
# Show original dendrogram
plot(d)
# Subset to first 10 labels
d1 <- subset(d, labels(d)[1:10])
plot(d1)
# Subset d1 to all except the first 2 labels
d2 <- subset(d1, labels(d1)[1:2], invert=TRUE)
plot(d2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.