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), ]

```
I think the solution by [@G. Grothendieck](https://stackoverflow.com/a/59231361/12158757) is so far the best. Here is another solution with `base R`.

Assuming you are using a data frame `df` which consists of `a`,`b`,`c` and `d`, i.e,

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

df <- data.frame(t(data.frame(a,b,c,d)))
> df
   X1  X2
a 3.0 7.0
b 4.0 6.0
c 2.0 6.0
d 3.5 6.5

```

then maybe the following code can help you to make convex union

```
l <- combn(df[,1],2,diff)
b <- combn(df[,2],2,diff)
idx <- combn(seq(nrow(df)),2)
m <- df[unique(as.vector(idx[,l*b<0])),]

> m
   X1  X2
a 3.0 7.0
b 4.0 6.0
d 3.5 6.5

```