File: corrRect.hclust.Rd

package info (click to toggle)
r-cran-corrplot 0.95-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,212 kB
  • sloc: sh: 13; makefile: 5
file content (77 lines) | stat: -rw-r--r-- 2,389 bytes parent folder | download
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/corrRect.hclust.R
\name{corrRect.hclust}
\alias{corrRect.hclust}
\title{Draw rectangles on the correlation matrix graph.}
\usage{
corrRect.hclust(
  corr,
  k = 2,
  col = "black",
  lwd = 2,
  method = c("complete", "ward", "ward.D", "ward.D2", "single", "average", "mcquitty",
    "median", "centroid")
)
}
\arguments{
\item{corr}{Correlation matrix for function \code{corrRect.hclust}. It use
\code{1-corr} as dist in  hierarchical clustering (\code{\link{hclust}}).}

\item{k}{Integer, the number of rectangles drawn on the graph according to
the hierarchical cluster, for function \code{corrRect.hclust}.}

\item{col}{Color of rectangles.}

\item{lwd}{Line width of rectangles.}

\item{method}{Character, the agglomeration method to be used for hierarchical
clustering (\code{\link{hclust}}). This should be (an unambiguous
abbreviation of) one of \code{'ward'}, \code{'ward.D'}, \code{'ward.D2'},
\code{'single'}, \code{'complete'}, \code{'average'}, \code{'mcquitty'},
\code{'median'} or \code{'centroid'}.}
}
\description{
Draw rectangles on the correlation matrix graph based on hierarchical cluster
(\code{\link{hclust}}).
}
\examples{
data(mtcars)
M = cor(mtcars)
corrplot(M, order = 'FPC') -> p
corrRect(p, index = c(1, 6, 11))

if(getRversion() >= '4.1.0') {
  corrplot(M, order = 'FPC') |> corrRect(index = c(1, 6, 11))
}

(order.hc = corrMatOrder(M, order = 'hclust'))
(order.hc2 = corrMatOrder(M, order = 'hclust', hclust.method = 'ward.D2'))
M.hc  = M[order.hc, order.hc]
M.hc2 = M[order.hc2, order.hc2]

par(ask = TRUE)

# same as: corrplot(M, order = 'hclust', addrect = 2)
corrplot(M.hc)
corrRect.hclust(corr = M.hc, k = 2)

# same as: corrplot(M, order = 'hclust', addrect = 3)
corrplot(M.hc)
corrRect.hclust(corr = M.hc, k = 3)

# same as: corrplot(M, order = 'hclust', hclust.method = 'ward.D2', addrect = 2)
corrplot(M.hc2)
corrRect.hclust(M.hc2, k = 2, method = 'ward.D2')

# same as: corrplot(M, order = 'hclust', hclust.method = 'ward.D2', addrect = 3)
corrplot(M.hc2)
corrRect.hclust(M.hc2, k = 3, method = 'ward.D2')

# same as: corrplot(M, order = 'hclust', hclust.method = 'ward.D2', addrect = 4)
corrplot(M.hc2)
corrRect.hclust(M.hc2, k = 4, method = 'ward.D2')
}
\author{
Taiyun Wei
}
\keyword{hplot}