Matching strings across columns in R
I've got a data frame with 2 character columns. I'd like to find the rows which one column contains the other, however grepl is being strange. Any ideas?


>`>` ( df <- data.frame(letter=c('a','b'),food = c('apple','pear','bun','beets')) )

>  letter  food

>1      a apple

>2      b  pear

>3      a   bun

>4      b beets 

>`>` grepl(df$letter,df$food)

>[1]  TRUE  TRUE FALSE FALSE

but i want T F F T

Thanks.
Matching strings across columns in R
===

I've got a data frame with 2 character columns. I'd like to find the rows which one column contains the other, however grepl is being strange. Any ideas?


>`>` ( df <- data.frame(letter=c('a','b'),food = c('apple','pear','bun','beets')) )

>  letter  food

>1      a apple

>2      b  pear

>3      a   bun

>4      b beets 

>`>` grepl(df$letter,df$food)

>[1]  TRUE  TRUE FALSE FALSE

but i want T F F T

Thanks.