corrRect: Draw rectangle(s) on the correlation matrix graph.

Description Usage Arguments Author(s) Examples

View source: R/corrRect.R

Description

Draw rectangle(s) around the chart of corrrlation matrix.

corrRect needs the number(parameter clus) of each cluster's members, while corrRect.hclust can get the members in each cluster based on hierarchical clustering (hclust).

Usage

1
2
3
4
corrRect(clus,  col = "black", lwd = 2)

corrRect.hclust(corr, k=2, col = "black", lwd = 2,
	method = c("complete", "ward", "single", "average","mcquitty", "median", "centroid"))

Arguments

clus

Vector, the number of each cluster's members.

corr

Correlation matrix for function corrRect.hclust. It use 1-corr as dist in hierarchical clustering (hclust).

k

Integer, the number of rectangles drawn on the graph according to the hierarchical cluster, for function corrRect.hclust.

col

Color of rectangles.

lwd

Line width of rectangles.

method

Character, the agglomeration method to be used for hierarchical clustering (hclust). This should be (an unambiguous abbreviation of) one of "ward", "single", "complete", "average", "mcquitty", "median" or "centroid".

Author(s)

Taiyun Wei

Examples

 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
data(mtcars)
M <- cor(mtcars)
corrplot(M, method="circle", order = "FPC")
corrRect(c(5,6))

(order.hc <- corrMatOrder(M, order="hclust"))
(order.hc2 <- corrMatOrder(M, order="hclust", hclust.method="ward"))
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", addrect=2)
corrplot(M.hc2)
corrRect.hclust(M.hc2, k=2, method="ward")

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

##same as: corrplot(M, order="hclust", hclust.method="ward", addrect=4)
corrplot(M.hc2)
corrRect.hclust(M.hc2, k=4, method="ward")

wmmurrah/corrplot documentation built on May 28, 2017, 5:12 a.m.