subset-dendrogram: Subsetting dendrogram objects

subset.dendrogramR Documentation

Subsetting dendrogram objects

Description

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.

Usage

## S3 method for class 'dendrogram'
subset(x, subset, invert=FALSE, ...)

Arguments

x

An object of class 'dendogram'

subset

A vector of labels to keep (see invert).

invert

If set to TRUE, subset to only the leaves not in subset.

...

Additional arguments for consistency with generic.

Value

An object of class 'dendrogram' corresponding to the subsetted tree.

Note

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.

Author(s)

Aidan Lakshman ahl27@pitt.edu

See Also

subset

Examples

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)

npcooley/SynExtend documentation built on Nov. 15, 2024, 3:02 p.m.