[R] data.frame merge matching several columns

Patrick E. McKnight pem at theriver.com
Tue Oct 8 20:17:35 CEST 2002


Greetings,

Is it possible to match several columns in a merge statement?  Here is my
problem:

data1 looks like this...

SUBID  TARGID  ITEM  RATING
1         1      1      4
1         1      2      5
1         1      3      3
1         1      4      2
1         1      5      5
......

SUBID is the ID for the raters, TARGID is the ID for the targets being
rated, ITEM ranges from 1 to 64 crossed by TARGID (i.e., all targets were
rated on 64 items), and RATING is the rating given by SUBID for each
TARGID and ITEM.

My second dataset looks like this data2:

TARGID  ITEM  TARGET
1        1      5
1        2      4
1        3      6
1        4      2
1        5      3
.......

TARGID again is the target's ID, ITEM ranges from 1 to 64, and TARGET is
the rating provided by the target.

I would like to merge these two data.frames by TARGID and ITEM to yield
the following structure:

SUBID  TARGID  ITEM  RATING  TARGET
1         1      1      4      5
1         1      2      5      4
1         1      3      3      6
1         1      4      2      2
1         1      5      5      3
........

I realize that merge appears to be the proper tool but there is no
documentation for how to merge by multiple columns.  Is this possible?

Thanks in advance for any assistance with the problem.


--
Cheers,

Patrick


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list