When I run my code, I get a warning:
Warning message:
In grepl(df$letter, df$food) :
argument 'pattern' has length > 1 and only the first element will be used
This is confirmed ?greplunder pattern:
If a character vector of length 2 or more is supplied,
the first element is used with a warning.
So grepl finds a in both the apple tree and the pear. This does not solve your problem (apply or one of its options?), But it explains the conclusion that you get.
source
share