[R] How to find the non matching vectors among these five, if so how we can find the non matching element of that vectors?

arun smartpink111 at yahoo.com
Fri Sep 7 00:41:39 CEST 2012


Hi,
Try this:


list1<-list(a=a,b=b,c=c,d=d,e=e)
dat1<-as.matrix(do.call(rbind,lapply(list1,`[`,1:4)))
dat1[duplicated(dat1)|duplicated(dat1,fromLast=TRUE),]
  [,1] [,2] [,3] [,4]
#a    1    2    3   NA
#c    1    2    3   NA
#d    1    2    3   NA

dat1[!(duplicated(dat1)|duplicated(dat1,fromLast=TRUE)),]
  #[,1] [,2] [,3] [,4]
#b    1    2    3    4
#e    1    4    5   NA

which(!(duplicated(dat1)|duplicated(dat1,fromLast=TRUE)))
#[1] 2 5


dat2<-dat1[!(duplicated(dat1)|duplicated(dat1,fromLast=TRUE)),]

 do.call(rbind,apply(dat2,2,function(x)x[!(duplicated(x)|duplicated(x,fromLast=TRUE))]))
     b  e
#[1,] 2  4
#[2,] 3  5
#[3,] 4 NA
A.K.

----- Original Message -----
From: Sri krishna Devarayalu Balanagu <balanagudevarayulu at gvkbio.com>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc: 
Sent: Thursday, September 6, 2012 4:40 AM
Subject: [R] How to find the non matching vectors among these five, if so how we can find the non matching element of that vectors?

Hello,

Say all the below five vectors should have same elements in any situation.
How to find the non matching vectors among these five, if so how we can find the non matching elements of those vectors?
Can anyone help?

a=c(1,2,3)
b=c(1,2,3,4)
c=c(1,2,3)
d=c(1,2,3)
e=c(1,4,5)
identical(a,b,c,d,e)
Visit us at Booth No. 5 at 2012 ChemOutsourcing Conference, 10-13 Sept 2012, Ocean Place Resort - Long Branch, NJ, United States

Visit us at Booth No. 4 at World Conference on Pharmacometrics, 5-7 Sept 2012, Grand Hilton Hotel, Seoul, Korea
________________________________
Notice: The information contained in this electronic mail message is intended only for the use of the designated recipient. This message is privileged and confidential. and the property of GVK BIO or its affiliates and subsidiaries. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by telephone +91-40-66929999<tel:%2B91-40-66929999> and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies).



    [[alternative HTML version deleted]]

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





More information about the R-help mailing list