File: find_dend.Rd

package info (click to toggle)
r-cran-dendextend 1.16.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,936 kB
  • sloc: sh: 13; makefile: 2
file content (61 lines) | stat: -rw-r--r-- 2,045 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/find_dend.R
\name{dend_expend}
\alias{dend_expend}
\alias{find_dend}
\title{Finds a "good" dendrogram for a dist}
\usage{
dend_expend(
  x,
  dist_methods = c("euclidean", "maximum", "manhattan", "canberra", "binary",
    "minkowski"),
  hclust_methods = c("ward.D", "ward.D2", "single", "complete", "average", "mcquitty",
    "median", "centroid"),
  hclust_fun = hclust,
  optim_fun = cor_cophenetic,
  ...
)

find_dend(x, ...)
}
\arguments{
\item{x}{A matrix or a data.frame. Can also be a \link{dist} object.}

\item{dist_methods}{A vector of possible \link{dist} methods.}

\item{hclust_methods}{A vector of possible \link{hclust} methods.}

\item{hclust_fun}{By default \link{hclust}.}

\item{optim_fun}{A function that accepts a dend and a dist and returns how the two
are in agreement. Default is \link{cor_cophenetic}.}

\item{...}{options passed from find_dend to dend_expend.}
}
\value{
dend_expend:
A list with three items. The first item is called "dends" and includes
a dendlist with all the possible dendrogram combinations. The second is "dists" and
includes a list with all the possible distance matrix combination.
The third. "performance", is data.frame with three columns: dist_methods, hclust_methods, and optim.
optim is calculated (by default) as the cophenetic correlation (see: \link{cor_cophenetic}) between the distance matrix and
the \link{cophenetic} distance of the hclust object.

find_dend: A dendrogram which is "optimal" based on the output from dend_expend.
}
\description{
There are many options for choosing distance and linkage functions for hclust.
This function goes through various combinations of the two and helps find the one
that is most "similar" to the original distance matrix.
}
\examples{

x <- datasets::mtcars
out <- dend_expend(x, dist_methods = c("euclidean", "manhattan"))
out$performance

dend_expend(dist(x))$performance

best_dend <- find_dend(x, dist_methods = c("euclidean", "manhattan"))
plot(best_dend)
}