我dplyr加入的技能是有點生疏,但我試圖加入兩個數據集看起來像這樣:如何在沒有主鍵的情況下加入新列?
L = c("a","a","a","a")
M = c("b","b","b","b")
N = c("c","c","c","c")
O = c("d","e","d","e")
P = c(1521,02915,12451,12)
DF1 <- data.frame(L,M,N,O,P)
L = c("a","a","a","a")
M = c("b","b","b","b")
N = c("c","c","c","c")
O = c("d","e","f","d")
Q = c(11,8805,1231,9012)
DF2 <- data.frame(L,M,N,O,Q)
什麼是一個很好的方式去參加這些所謂P和Q是與同在一起LMNO列?我不確定是否有一種方法可以生成在dplyr中加入的主鍵。
我不認爲這是一個合法經營的事情:
DF3 <- left_join(DF1,DF2)
,因爲我在DF2失去O欄從得到的加入。我覺得我在這裏的東西很簡單......
爲什麼不試試'合併(DF1,DF2)'? ? – DatamineR
如果要保留所有行,請使用'full_join'而不是'left_join'。 – Gregor
@DatamineR可能的原因:'merge'可能會比較慢,並且可能會混亂行序。 – Gregor