Skip to content

setdiff for data.frames?

3 messages · Jason Rupert, Gabor Grothendieck, G. Jay Kerns

#
I have two data.frames.

One is the subset of the other.  I need to determine what rows were removed from the superset data.frame to form the subset data.frame. 

I was hoping to turn up functionality similar to setdiff for data.frames, but did not have any luck.   It seems I need to find a function that performs the oposite as "merge".
[1] 248  31
[1] 214  31

Thank you for any suggestions of functions that might exist that might help.
#
Try this:

library(sqldf)
BODsub <- BOD[1:3,]
sqldf("select * from BOD except select * from BODsub")

For more see: http://sqldf.googlecode.com
On Thu, Mar 12, 2009 at 5:58 PM, Jason Rupert <jasonkrupert at yahoo.com> wrote:
#
Dear Jason,

On Thu, Mar 12, 2009 at 6:11 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
Also, please see

http://finzi.psych.upenn.edu/R/R-devel/archive/26683.html

and as a consequence of that discussion:

library(prob)
setdiff(A,B)

Best,
Jay





***************************************************
G. Jay Kerns, Ph.D.
Associate Professor
Department of Mathematics & Statistics
Youngstown State University
Youngstown, OH 44555-0002 USA
Office: 1035 Cushwa Hall
Phone: (330) 941-3310 Office (voice mail)
-3302 Department
-3170 FAX
E-mail: gkerns at ysu.edu
http://www.cc.ysu.edu/~gjkerns/