[R] How to find the non matching vectors among these five, if so how we can find the non matching element of that vectors?
David Winsemius
dwinsemius at comcast.net
Thu Sep 6 20:20:57 CEST 2012
On Sep 6, 2012, at 1:40 AM, Sri krishna Devarayalu Balanagu wrote:
> 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?
"non-matching" is not a well-defined mathematical expression. What is the "right answer" to you question?
> 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)
The `identical function only takes two arguments.
For instance, does majority rule if there are multiple duplicated items?
> a=c(1,2,3)
> b=c(1,2,3,4)
> c=c(1,2,3)
> d=c(1,2,3)
> e=c(1,2,3,4)
This will identify the items that are identical to the first duplicated item:
list(a=a,b=b,c=c,d=d,e=e) %in%
list(a=a,b=b,c=c,d=d,e=e)[duplicated( list(a=a,b=b,c=c,d=d,e=e) )][1]
[1] TRUE FALSE TRUE TRUE FALSE
--
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list