I want to transform the following loop into apply/lapply syntax in order to make it more efficient:
for (i in seq(1, nrow(df)) {
is.element(df$a[i], unlist(strsplit(df$b[i], "/")))
}
I have tried this:
is.element(df$a, unlist(strsplit(df$b[i], "/")))
But it does not work because of the unlist statement.
Also tried:
mapply(is.element, df$a, unlist(strsplit(df$b, "/")))
Example of the data:
print(df$a)
[1] "A" "G" "T" "A" "CCG"
print(df$b)
[1] "G/A" "C/TTTTTA" "C/-" "A/G" "G/A/C"