我必須組合兩個看起來像這樣的數據幀 我想要在數據幀之間採用公共列並將它們連接在一起。 兩個數據幀中的行將完全不同。根據公共列將R中的兩個數據幀組合起來
a b c
row1 1 0 1
row2 1 0 1
另據幀
d a c f
row3 1 0 1 1
row4 1 1 0 0
我想最終的數據集看起來像這樣
a c
row1 1 1
row2 1 1
row3 0 1
row4 1 0
來自兩位dataframes
dput(x1)
structure(list(d = c(1L, 1L), a = 0:1, c = c(1L, 0L), f = c(1L,
0L)), .Names = c("d", "a", "c", "f"), row.names = c("row3", "row4"
), class = "data.frame")
dput(x2)
structure(list(a = c(1L, 1L), b = c(0L, 0L), c = c(1L, 1L)), .Names = c("a",
"b", "c"), row.names = c("row1", "row2"), class = "data.frame")
'merge' ........ – Thomas