I think I'm in the right direction with this code, but I'm not quite there yet.
I tried to find something useful on Google and SE, but I didn't seem to be able to formulate the question in such a way as to get the answer I'm looking for.
I could write a for-loop for this, comparing for each id and for each unique value for each row, but I am trying to achieve a higher level of R-understanding and therefore want to avoid loops.
id <- c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5)
a <- c(1,1,1,2,2,2,3,3,4,4,4,5,5,5,6)
b <- c(1,2,3,3,3,4,3,4,5,4,4,5,6,7,8)
require(data.table)
dt <- data.table(id, a, b)
dt
dt[,unique(a) %in% b, by=id]
tmp <- dt[,unique(a) %in% b, by=id]
tmp$id[tmp$V1 == FALSE]
2, 3 5 , : " id, , a, , b ".
2 5, 3. , ID 3 4 4 .
, , , , .