Hi R users

I am trying to find unmatched data from two dataframes. I would like to
find unmatched data based on several factors. For the following data:

dat1 <- data.frame(x = paste("A", 1:6, sep=""), 
                  y = c("andy","bob","ciaran","dan", "eion", 
                           "fred")) 
dat1


dat2 <- data.frame(x = paste("A", c(1,2,3,5,6), sep=""), 
                  y = c("andy", "bob", "ciaran", 
                           "dan", "zane"),z=c(10,20,30,40,50))  

dat2


I would like to know data that from dat2 that doesn't appear in dat1
based on both the x and y factors ie (A5, dan, 40) and (A6,zane, 50).

I have tried two approaches but have not been successful

? nomatch <- subset(dat1, is.element(?) == FALSE)
? setdiff(dat1$x,dat2$y)

Any thoughts would be great

Regards

Andy

Andrew McFadden MVS BVSc
Incursion Investigator
Investigation & Diagnostic Centres - Wallaceville Biosecurity New 
Zealand Ministry of Agriculture and Forestry

Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: 
Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St 
Upper Hutt


########################################################################
This email message and any attachment(s) is intended solely for the
addressee(s) named above. The information it contains is confidential
and may be legally privileged.  Unauthorised use of the message, or the
information it contains, may be unlawful. If you have received this
message by mistake please call the sender immediately on 64 4 8940100
or notify us by return email and erase the original message and
attachments. Thank you.

The Ministry of Agriculture and Forestry accepts no responsibility for
changes made to this email or to any attachments after transmission from
the office.
########################################################################

        [[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.

Reply via email to