Question: I have 3 vectors 

```
a = c(3,7) 
b = c(4,6)
c = c(2,6) 

```

I would like to make the union of these 3 sets. I could use the `union()` function but "convex" union requires that the vector `c` is removed from the union because it is dominated by a, which is higher for the two elements. 

Any idea of a simple way to do it?

Answer: 
If each row of `m` is a pair then `which.nondominated(-t(m))` gives the row numbers of the rows not dominated by some other row. The code is written in C so it should be fast.

```
library(ecr)
m <- rbind(a, b, c) # input data

ix <- which.nondominated(-t(m))    # 1, 2
mm <- m[ix, ]
mm
##   [,1] [,2]
## a    3    7
## b    4    6

```

There are no duplicates in this example but if there could be and if you also wanted to remove them then:

```
unique(mm)

```

or

```
mm[!duplicated(mm), ]

```
This will work in the cases mentioned above in the comments.

```
a = c(3,7) 
b = c(4,6)
c = c(2,6)
d = c(3.5,6.5)

my_fun <- function(A){
  B <- matrix(NA,ncol=ncol(A))
  for(i in 1:nrow(A)){
    include <- !any(apply(A[-i,],1,function(x){all(A[i,] < x)}))
    if(include){
      B <- rbind(B,A[i,])
    }
  }
  na.omit(B)
}

A <- rbind(a,b,c,d)
my_fun(A)

     [,1] [,2]
[1,]  3.0  7.0
[2,]  4.0  6.0
[3,]  3.5  6.5

```