如何将2个矩阵组合成一个图
我有 2 个对称矩阵(矩阵的数学意义),其中一个具有位置之间的距离(位置用 4 位数字编码:2030、2059、2095...),如下所示:2030 2059 2095 ...
2030 北美 59328 68464
2059 59328 北美 37196
2095 68464 37196 不适用
...
以及另一个位置之间的相关性:2030 2059 2095...
2030 1.0000000 0.4651804 0.6185849
2059 0.4651804 1.0000000 0.4428746
2095 0.6185849 0.4428746 1.0000000
...
我需要将这两个矩阵组合成相关性与距离的关系图,但不知道如何在 R 中执行此操作,并且考虑到我有超过 80 个位置,我不想手动执行此操作!有谁知道有什么方法可以做到吗?
谢谢!
I have 2 symmetric matrices (mathematical meaning of matrices), one with distances between locations (the locations are coded with 4 digit numbers:2030, 2059, 2095...) that looks like this:2030 2059 2095 ...
2030 NA 59328 68464
2059 59328 NA 37196
2095 68464 37196 NA
...
and another with the correlations between locations :2030 2059 2095...
2030 1.0000000 0.4651804 0.6185849
2059 0.4651804 1.0000000 0.4428746
2095 0.6185849 0.4428746 1.0000000
...
I need to combine these 2 matrices in a plot of correlations vs. distances but have no idea how to do it in R and considering I have more than 80 locations I don't want to do it manually! Does anyone know of a way to do it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只想将相关性绘制为距离的函数,而不在绘图上强加特定的结构,您可以提取各自矩阵的下部,例如
If you just want to plot correlations as a function of distances, without imposing a particular structure on your plot, you can just extract the lower part of your respective matrices, e.g.
假设您的矩阵存储在
m1
和m2
中,这是否有效:Assuming your matrices are stored in
m1
andm2
, does this work: