Generate a dendrogram
create.dendrogram.Rd
Takes a matrix and creates a row-wise or column-wise dendrogram
Usage
create.dendrogram(
x,
clustering.method = 'diana',
cluster.dimension = 'col',
distance.method = 'correlation',
cor.method = 'pearson',
force.clustering = FALSE,
same.as.matrix = FALSE
);
Arguments
- x
A matrix that is used to create the dendrogram
- clustering.method
Method used to cluster the records (can not be none). Accepts all agglomerative clustering methods available in hclust, plus “diana” (which is divisive).
- cluster.dimension
Should clustering be performed on the rows or columns of x?
- distance.method
Method name of the distance measure to be used for clustering. Defaults to “correlation”. Other supported methods are same as in ?dist. Also supports “jaccard” which is useful for clustering categorical variables.
- cor.method
The method used for calculating correlation. Defaults to “pearson”
- force.clustering
Binary to over-ride the control that prevents clustering of too-large matrices
- same.as.matrix
Prevents the flipping of the matrix that the function normally does
Value
Returns an object of the dendrogram class corresponding to the row-wise or column-wise dendrogram for x
Examples
# create temp data
x <- outer(-5:5, -5:5, '*') + matrix(nrow = 11, ncol = 11, data = runif(11 * 11));
colnames(x) <- paste('col', 1:11, sep = '-');
rownames(x) <- paste('row', 1:11, sep = '-');
# example of generating a column-wise dendrogram using default values
create.dendrogram(
x = x
);
#> 'dendrogram' with 2 branches and 11 members total, at height 1.999704
# example of generating a column-wise dendrogram using different distance and clustering methods
create.dendrogram(
x = x,
clustering.method = 'median',
cluster.dimension = 'cols',
distance.method = 'euclidean'
);
#> 'dendrogram' with 2 branches and 11 members total, at height 42.19573
# generate row-wise dendrogram using default distance and clustering methods
create.dendrogram(
x = x,
cluster.dimension = 'row'
);
#> 'dendrogram' with 2 branches and 11 members total, at height 1.999885
# generate row-wise dendrogram using different distance and clustering methods
create.dendrogram(
x = x,
clustering.method = 'ward',
cluster.dimension = 'rows',
distance.method = 'manhattan'
);
#> The "ward" method has been renamed to "ward.D"; note new "ward.D2"
#> 'dendrogram' with 2 branches and 11 members total, at height 611.0403