Skip to content
Prev 165894 / 398502 Next

Equivalent of match for data.frame

On Sat, 3 Jan 2009, Carlos J. Gil Bellosta wrote:

            
I don't think that is what is intended (it does not give the quoted result 
in 'S'), but I don't actually know (and we were not told what 'S' this 
is).  My guess is that the whole row has to match element by element. 
For that I would hash rows as in duplicated.data.frame.  Something like

match.data.frame <- function(x, table, ...)
     match(do.call("paste", c(x, sep = "\r")),
           do.call("paste", c(table, sep = "\r")), ...)

maybe with some added as.data.frame() calls for safety.