mydf <- tibble::tribble(
~seq, ~flag,
0, 0,
0, 0,
0, 0,
1, 1,
1, 1,
7, 1,
1, 1,
3, 1,
2, 1,
1, 1,
1, 1,
0, 1,
0, 1,
0, 0,
0, 0,
1, 1,
1, 1,
7, 1,
1, 1,
3, 1,
2, 1,
1, 1,
1, 1,
0, 1,
0, 1,
0, 0,
0, 0,
2, 0
)
I have a dataframe with a sequence column. How can I create a binary flag to mark any particular number sequence? My example sequence is 1, 1, 7, 1, 3, 2, 1, 1, 0, 0.