I have a big data frame in which I would like to flag the rows as follows:
within each group, I want to find whether any col1 value is present in col2 column. If so, mark those lines where same values appear.
this is my dataset with the desired flag values:

my try was the following:
df %>%
group_by(attr) %>%
mutate(flag=ifelse(any(col1)==any(col2), 1, 0))
but it does not work.
thanks in advance!