Given a list of vectors:
x <- list(c("street_address", "poi", "point"), c("route", "interest", "point_of_interest"))
x
[[1]]
[1] "street_address" "poi" "point"
[[2]]
[1] "route" "interest" "point_of_interest"
.. I' like to use stringr::str_which
(which is a wrapper of which
around str_detect
) to detect the vector which contains an exact match of a given word.
Example:
str_which(x, "poi")
returns
[1] 1 2
because (as far as I understand it) "poi" is both contained in "poi" and "point" of the first vector, but also in "point_of_interest" of the second vector.
That's why I used anchors, like so:
str_which(x, "^poi$")
But this returns:
integer(0)
So, anchors don't seem to work. What to do here?