我正在使用R和我有合併向量矩陣中的問題。合併矩陣和向量使用R
所以,basicaly,這裏是我有:
A=
["A"] ["B"] ["C"] ["D"]
[1,] 0.2 0.1 0.2 0.8
B=
["A"] ["B"] ["E"] ["F"] ["G"]
[1,] 0.2 0.1 0.2 1 1.2
而且我想我的結果是:
C =
["A"] ["B"] ["E"] ["F"] ["G"] ["C"] ["D"]
[1,] 0.2 0.1 0.2 0 0 0.2 0.8
[2,] 0.2 0.1 0.2 1 1.2 0 0
(行順序並不重要)
dput(a)
structure(c(0.2, 0.1, 0.2, 0.8), .Dim = c(1L, 4L), .Dimnames = list(NULL, c("A", "B", "C", "D")))
dput(b)
structure(c(0.2, 0.1, 0.2, 1, 1.2), .Dim = c(1L, 5L), .Dimnames = list(NULL, c("A", "B", "E", "F", "G")))
請閱讀http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example,然後提供我們有一些可重複的數據。目前還不清楚數據的真實結構,即矢量或矩陣。簡而言之:將'dput(A)'和dput('B')的結果粘貼到你的問題中。 – Andrie 2012-03-19 14:35:02
對不起,這裏是你要求的dput()。結構(c(0.2,0.1,0.2,0.8),.Dim = c(1L,4L),.Dimnames = list(NULL,c(「A」,「B」,「 (c,0.2,0.1,0.2,1,1.2),.Dim = c(1L,5L),.Dimnames = list(NULL, c(「A」,「B」,「E」,「F」,「G」))) – user1278743 2012-03-19 14:47:36