Hi Mark
as you guessed it, I meant a dataframe of the rows in DF1 that are not in DF2 .

Here is what I got:
> complement<-setdiff(DF1$V2,DF2$V2)
> DF1[,complement]
Error in `[.data.frame`(DF1, , complement) : undefined columns selected
> 


----- Original Message ----
From: Mark Leeds <markleeds@verizon.net>
To: joseph <jdsandjd@yahoo.com>
Cc: markleeds@hitecapital.com
Sent: Sunday, September 14, 2008 10:07:48 AM
Subject: RE: [R] difference of two data frames

Hi: If you mean a dataframe of the rows in DF1 that are not in DF2 , then I
think below will work for the letters, which , according to what I'm
understanding, will also make it work for the rows so no need to
consider the numbers ?

complement<-setdiff(DF1$V2,DF2$V2)
DFnew<=DF1[,complement)

But, 3 things to consider:

1) I'm not sure if I understand the problem. 

2) I'm also at home and I don't use R here so I can't test it.  

3) I'm also not sure about the order of the setdiff operation so you may
have to switch the order of the two columns I used.

Atleast,  it will get you started though and I'm confident someone else will
answer. Good luck.





-----Original Message-----
From: r-help-bounces@r-project.org [mailto:r-help-bounces@r-project.org] On
Behalf Of joseph
Sent: Sunday, September 14, 2008 12:50 PM
To: r-help@r-project.org
Cc: r-help@r-project.org
Subject: [R] difference of two data frames

Hello
I have 2 data frames DF1 and DF2 where DF2 is a subset of DF1:
DF1= data.frame(V1=1:6, V2= letters[1:6])
DF2= data.frame(V1=1:3, V2= letters[1:3])
How do I create a new data frame of the difference between DF1 and DF2
newDF=data.frame(V1=4:6, V2= letters[4:6])
In my real data, the rows are not in order as in the example I provided.
Thanks much
Joseph


      
    [[alternative HTML version deleted]]

______________________________________________
R-help@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.


      
	[[alternative HTML version deleted]]

