I'd like to compare column A in a tibble to column B to see if an element in column A is present in column B. Column A is a character vector. Column B is a list of character vectors. I'd like to do this line by line. I can do this with a loop.
library(tidyverse)
my.tibble = c('a','b','c') %>% tibble
my.list = list(c('a','b'),c('b','c'),c('d','e'))
my.tibble = my.tibble %>% add_column(my.list)
its.in.it = as.list(NULL)
for (i in 1:nrow(my.tibble)){
its.in.it[[i]] = my.tibble[i,1] %in% unlist(my.tibble[i,2])
}
my.tibble$its.in.it = unlist(its.in.it)
my.tibble
I'm trying to do this with dplyr/purrr or apply. I'm not sure if I should group or nest or split, and there are a lot of combinations.