8.相关图
相关图 辅佐我们想像数据相关阐明. 具体信息参考 Corrgrams: Exploratory displays for
correlation matrices.
在 R 中, 相关图是通过corrgram 包里函数corrgram(x, order = , panel=, lower.panel=, upper.panel=,text.panel=, diag.panel=) 来实现的.
选项
x 是数据框,它的每一行是一个调查数据.
order=TRUE 是让变量按主身分阐明相关矩阵分列.
panel= 参考非对角面板. 你可以用lower.panel= 和 upper.panel= 来选择别离主对角线下面和上面差异选项. text.panel= 和 diag.panel= 参照主对角线. 可用的参数如下.
off diagonal panels
panel.pie (the filled portion of
the pie indicates the magnitude of the correlation)
panel.shade (the depth of the
shading indicates the magnitude of the correlation)
panel.ellipse (confidence ellipse and
smoothed line)
panel.pts (scatterplot)
main diagonal panels
panel.minmax (min and max values of
the variable)
panel.txt (variable name).
# First Correlogram Examplelibrary(corrgram)
corrgram(mtcars,
order=TRUE, lower.panel=panel.shade,
upper.panel=panel.pie, text.panel=panel.txt,
main=”Car Milage Data in
PC2/PC1 Order”)

# Second Correlogram Example
library(corrgram)
corrgram(mtcars,
order=TRUE, lower.panel=panel.ellipse,
upper.panel=panel.pts, text.panel=panel.txt,
diag.panel=panel.minmax,
main=”Car Milage Data in
PC2/PC1 Order”)

# Third Correlogram Example
library(corrgram)
corrgram(mtcars,
order=NULL, lower.panel=panel.shade,
upper.panel=NULL, text.panel=panel.txt,
main=”Car Milage Data
(unsorted)”)

8.1改变相关图中颜色
你可以改变相关图中的颜色,通过指定在colorRampPalette( ) 函数和 col.corrgram( ) 函数的4种颜色. 以下是个个例子.
12下一页
