Merge data.frames with duplicates

前端 未结 3 1422
囚心锁ツ
囚心锁ツ 2020-12-11 20:29

I have many data.frames, for example:

df1 = data.frame(names=c(\'a\',\'b\',\'c\',\'c\',\'d\'),data1=c(1,2,3,4,5))
df2 = data.frame(names=c(\'a\',\'e\',\'e\',         


        
3条回答
  •  温柔的废话
    2020-12-11 21:25

    See other questions:

    • How to join data frames in R (inner, outer, left, right)
    • recombining-a-list-of-data-frames-into-a-single-data-frame
    • ...

    Examples:

    library(reshape)
    out <- merge_recurse(L)
    

    or

    library(plyr)
    
    out<-join(df1, df2, type="full")
    out<-join(out, df3, type="full")
    *can be looped
    

    or

    library(plyr)
    out<-ldply(L)
    

提交回复
热议问题