I have a dataframe such as :

```
Groups Element 
G1     E1
G2     E1
G1     E2
G1     E3
G1     E4
G1     E5
G2     E5
G2     E5
G2     E6
G1     E6
G1     E7

```

and I would like to create a new column called **Element2** for **G1** and **G2 groups**, which will have the **Element value** only if this element is in **G1 and G2 group**.

I should then get:

```
Groups Element Element2
G1     E1      E1
G2     E1      E1
G1     E2      NA
G1     E3      NA
G1     E4      NA
G1     E5      E5
G2     E5      E5
G2     E5      E5
G2     E6      E6
G1     E6      E6
G1     E7      NA

```

Here is the dput format of the table if it can helps:

```
structure(list(Groups.Element = c("G1     E1", "G2     E1", "G1     E2", 
"G1     E3", "G1     E4", "G1     E5", "G2     E5", "G2     E5", 
"G2     E6", "G1     E6", "G1     E7")), class = "data.frame", row.names = c(NA, 
-11L))

```