[英]R correlation heatmap: showing only values in the threshold
Here is the code (library: corrplot): 这是代码(库:corrplot):
df <- read.table(header=T, text="v1 v2 v3 v4
1 1 5 3 2
2 2 4 4 5
3 3 3 5 1
4 4 2 1 3
5 5 1 2 4
")
cormat<-cor(df)
corrplot(cormat)
I would like to show in the heatmap ONLY the dots for the correlation coefficients between -0.2 and +0.2 (all others I would like to be just empty white squares). 我只想在热图中显示-0.2和+0.2之间的相关系数的点(所有其他我想都只是空白的正方形)。 Could somebody help please?
有人可以帮忙吗?
Just set the unwanted values to zero: 只需将不需要的值设置为零:
tmp = cormat # Copy matrix
tmp[ tmp < -0.2 | tmp > 0.2 ] = 0
corrplot(tmp)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.