[R] combine the data frames into comma separated list.

Dr. D. P. Kreil (Boku) David.Kreil at boku.ac.at
Tue Jun 14 00:35:57 CEST 2011


Hi, try

?merge

Best,
David.


On 13 June 2011 23:48, Mary Kindall <mary.kindall at gmail.com> wrote:
> Hi R users,
> I am new to R and am trying to merge data frames in the following way.
> Suppose I have n data frames each with two fields. Field 1 is common among
> data frames but may have different entries. Field 2 is different.
>
>
> Data frame 1:
>
> Src   Target1
> 1        aaa
> 1        bbb
> 1        ccc
> 2        aaa
> 3        ddd
>
>
> Data frame 2:
>
> Src   Target2
> 2        aaaa
> 3        dddd
> 4        bbbb
> 4        eeee
> 4        ffff
>
>
> Data frame 3:
>
> Src   Target3
> 1        xx
> 3        yy
> 5        zz
> 6        tt
> 6        uu
>
> And so on...
>
> I want to convert this into a data frame something similar to:
> Src   Target1                   target2
> target3
> 1      aaa,bbb,ccc            -                                           xx
>
> 2      aaa                        aaaa                                     -
> 3      ddd                        dddd
> yy
> 4      -                            bbbb,eeee,ffff                         -
>
> 5      -
> -                                            zz
> 6      -
> -                                           tt,uu
>
>
> Basically I am trying to make a consolidated table.
>
> Help appreciated.
> Thanks
> M
>
>
> -------------
> Mary Kindall
> Yorktown Heights
> USA
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list