Hello,

you have the following problem: Your index `i`

and `j`

are along your vector **entries**, not the **positions**. This will work without an error:

```
library(dplyr)
#>
#> Attache Paket: 'dplyr'
#> Die folgenden Objekte sind maskiert von 'package:stats':
#>
#> filter, lag
#> Die folgenden Objekte sind maskiert von 'package:base':
#>
#> intersect, setdiff, setequal, union
data1 <- letters[1:5]
data2 <- c("a", "c", "e")
for (i in seq_along(data1)){
for (j in seq_along(data2)){
if_else(data1[[i]] == data2[[j]],
paste0(data1[[i]], "*"),
data1[[i]])
}
}
```

^{Created on 2022-08-20 by the reprex package (v2.0.1)}

If you wish to keep the result, you have to define a variable which allows replacement (e.g. replace inside `data1`

with `data1[[i]] <- `

or define a new variable).

```
library(dplyr)
#>
#> Attache Paket: 'dplyr'
#> Die folgenden Objekte sind maskiert von 'package:stats':
#>
#> filter, lag
#> Die folgenden Objekte sind maskiert von 'package:base':
#>
#> intersect, setdiff, setequal, union
data1 <- letters[1:5]
data2 <- c("a", "c", "e")
for (i in seq_along(data1)){
for (j in seq_along(data2)){
data1[[i]] <- if_else(data1[[i]] == data2[[j]],
paste0(data1[[i]], "*"),
data1[[i]])
}
}
data1
#> [1] "a*" "b" "c*" "d" "e*"
```

^{Created on 2022-08-20 by the reprex package (v2.0.1)}

Kind regards