I am trying to find a way to do a join on two dataframes but instead of a straight match ( test<-inner_join(blood, behavior, by = c("IDy" = "IDx")) ) I want to be able to have '1|3|546' be separated into individual elements and match on the join (like '042' %in% '1|2|3|042'). The only way I can think of is to create 3 additional lines with each value on a new line (1, 2, 3, 042) but I'll rather keep all in one cell. I'm not sure if this is a crazy idea.
# Creating behavior dataframe
IDx <- c('1|3|546', '1|2|3|983', '1|2|3|042', '952', '853', '061')
diet <- c("veg", "pes", "omni", "omni", "omni", "omni")
exercise <- c("high", "low", "low", "low", "med", "high")
behavior <- data.frame(IDx, diet, exercise)
# Creating blood dataframe
IDy <- c('983', '952', '853', '061', '042', '581', '249', '467', '841', '546')
blood_levels <- c(43543, 465, 4634, 94568, 850, 6840, 5483, 66452, 54371, 1347)
blood <- data.frame(IDy, blood_levels)