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

Richard M. Heiberger rmh at temple.edu
Thu Sep 6 20:11:41 CEST 2012


This should get you started.

Rich


aa <- c(1,2,3)
bb <- c(1,2,3,4)
cc <- c(1,2,3)
dd <- c(1,2,3)
ee <- c(1,4,5)


outer.all.equal <- function(input.list) {
  nn <- names(input.list)
  if (is.null(nn)) stop("input must be a named list.")
  n <- length(input.list)
  result <- vector("list", n*n)
  dim(result) <- c(n, n)
  dimnames(result) <- list(nn, nn)

  for (i in nn)
    for (j in nn)
      result[[i, j]] <- all.equal(input.list[[i]], input.list[[j]])
  result
}

outer.all.equal.TRUE <- function(x) {
  y <- array(vector(length=length(x)), dim(x), dimnames(x))
  y[] <- sapply(result, function(x) length(x)==1 && x == TRUE)
  y
}

input.list <- list(aa=aa, bb=bb, cc=cc, dd=dd, ee=ee)
result <- outer.all.equal(input.list)

result
str(result)
outer.all.equal.TRUE(result)


On 9/6/12, Sri krishna Devarayalu Balanagu
<balanagudevarayulu at gvkbio.com> 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?
> 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