Columnwise

Puzzle of Conditions in dplyr

Puzzle I am not sure how do I condition on whether a value in column A appears in column B? I use the naive way value A %in% column B within a mutate function. It workers such that R would search all values in column B. What’s more, it even works within groups. However, I not sure whether it is a luck or a right way to do it? Example library(dplyr, warn.