Thanks for the help. I made a reprex to clarify the problem:
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3.0 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa
#> 4 4.6 3.1 1.5 0.2 setosa
#> 5 5.0 3.6 1.4 0.2 setosa
#> 6 5.4 3.9 1.7 0.4 setosa
for(Species in iris) {
print(grep(Species, iris$Petal.Width, perl = , value = F))
}
#> [1] 1 2 3 4 5 8 9 11 12 15 21 23 25 26 28 29 30 31 34 35 36 37 39
#> [24] 40 43 47 48 49 50
Now the loop returns (I removed the warnings in this case, but is irrelevant to illustrate the problem) the row numbers of the species. In my case, I have 50 specie values, and gives the same output, but then a lot of row numbers. I want that the loop merges all the numbers to indicate if a value is missing. A first step:
for(Species in iris) {
x <- grep(Species, iris$Petal.Width, perl = , value = F)
}
#> Warning in grep(Species, iris$Petal.Width, perl = , value = F): argument
#> 'pattern' has length > 1 and only the first element will be used
#> Warning in grep(Species, iris$Petal.Width, perl = , value = F): argument
#> 'pattern' has length > 1 and only the first element will be used
#> Warning in grep(Species, iris$Petal.Width, perl = , value = F): argument
#> 'pattern' has length > 1 and only the first element will be used
#> Warning in grep(Species, iris$Petal.Width, perl = , value = F): argument
#> 'pattern' has length > 1 and only the first element will be used
#> Warning in grep(Species, iris$Petal.Width, perl = , value = F): argument
#> 'pattern' has length > 1 and only the first element will be used
x
#> integer(0)
However, a lot of warnings appear. I want that x in this case returns all the row numbers where species appear. So I am able to locate the missing values.