Please help me with this I have a data table as below
dt2 <- data.table(ID = c(1,1,2,2,3,3,4,4,4), variable = c("a","b","a","c","c","d","e","b","a"))
dt3 <- dt2[, list(variables = paste(variable, collapse = " | ")), by = ID]
dt3[,chk:=sample(letters[1:2])]
dt3
ID variables chk
1: 1 a | b b
2: 2 a | c a
3: 3 c | d b
4: 4 e | b | a a
I want to filter records where variables contain chk. In the example above row 3 should be removed.