繁体   English   中英

R热图-要求可视化与所有变量相关

[英]R heatmap - requesting visualization with correlation to all variables

我正在尝试根据教程构建一个“热图”。 我的data.frame看起来像这样:

在此处输入图片说明

结果看起来像这样:

在此处输入图片说明

码:

row.names(data) <-data$X)
data<-data[,2:5]
data_matrix<-data.matrix(data)
heat_result<-heatmap(data_matrix, Rowv=NA, Colv=NA, col = heat.colors(256), scale="column", margins=c(5,10))

我的问题是:如果您查看三月份Bing和百度的data.frame(以黄色标记),则热图上的结果是相同的(均为红色)。 我假设热图显示的是几个月内特定“搜索引擎”的颜色,而不是其他所有搜索引擎的颜色。 那么,如何设置热图以使颜色结果相对于所有其他搜索引擎而言呢? 我希望三月份看到红色的Bing。

您可以使用scale参数更改缩放比例。 将其更改为“ none”将防止在绘制颜色之前在整个列上重新缩放。 下面的最后一行代码是您想要的。

https://stat.ethz.ch/R-manual/R-devel/library/stats/html/heatmap.html

set.seed(42)

#uniform sampling, b is much larger than a
a = runif(10,1,10)
b = runif(10,10,100)

data = as.matrix(cbind(a,b))

#scale across columns
heatmap(data, Rowv=NA, Colv=NA, col = heat.colors(256), scale="column", margins=c(5,10))

#color across whole dataset.
heatmap(data, Rowv=NA, Colv=NA, col = heat.colors(256), scale="none", margins=c(5,10))

图片:

这是scale =“ column”: 按列缩放

这是scale =“ none”: 没有规模

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM