R的合并功能,按行名称合并数据帧

时间:2019-03-11 20:11:39

标签: r

我正在尝试合并两个具有不同行数但匹配行名的数据框。这是我所拥有的:

> head(counts.0hpi$counts)
                   r1      r2      r3      r4      r5
Cluster_1     588.148 621.756 596.124 618.485 590.202
Cluster_10    469.730 509.523 523.748 476.219 518.317
Cluster_1000  117.801 115.956 121.915  95.635 123.563
Cluster_10000 519.337 477.910 486.273 477.311 498.591
Cluster_10001 385.777 382.447 393.380 366.418 389.452
Cluster_10002  10.000  17.000   7.000  14.000  10.000

> head(counts.72hpi$counts)
                   r1      r2      r3      r4      r5
Cluster_1      35.083  31.018  39.044  32.033  26.045
Cluster_10    132.370 120.348 100.381 109.481 117.742
Cluster_100    67.274  77.491  56.541  56.527  56.630
Cluster_10000  39.784  32.709  24.529  25.004  23.961
Cluster_10001   6.000   6.000  10.000   9.000  10.000
Cluster_10002   4.904   7.963   4.000   4.000   7.962

> all <- merge(counts.0hpi$counts, counts.72hpi$counts, by = union(rownames(counts.0hpi$counts), rownames(counts.72hpi$counts)))
Error in fix.by(by.x, x) : 'by' must specify uniquely valid columns

我怎么了?非常感谢

0 个答案:

没有答案