找回密码
 注册
查看: 5308|回复: 0

R语言-将数值的矩阵映射为一个颜色方格的矩阵

  [复制链接]
发表于 2011-12-30 16:35:34 | 显示全部楼层 |阅读模式
本帖最后由 genechip 于 2011-12-31 17:05 编辑

fig1.PNG
data(mtcars)
  fit = lm(mpg~., mtcars)
  cor = summary(fit, correlation = TRUE)$correlation
  #相关阵上下倒转再转置,是为了让画出的图和相关阵方向一致
  cor2 = t(cor[11:1,])
  #下面颜色取自ellipse包中的plotcorr函数的示例
  colors = c("#A50F15", "#DE2D26", "#FB6A4A", "#FCAE91", "#FEE5D9",
   "white", "#EFF3FF","#BDD7E7", "#6BAED6", "#3182BD", "#08519C")
  image(1:11,1:11, cor2, axes = FALSE, ann = F,col = colors)
  text(rep(1:11, 11),rep(1:11, each = 11), round(100 * cor2))

fgg.png

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-21 23:50 , Processed in 0.027192 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表