Hi all I wish to know if this is possible. I am still exploring.
For example, I had this data set
Case Date Item
1 2016-03-25 Al
We can try
data %>%
group_by(Date) %>%
mutate(combiflag=any(grepl("Alpha", Item)) & any(grepl("Bravo", Item)))
Or it can be
data %>%
group_by(Date) %>%
mutate(combiflag= if(any(grepl("Alpha", Item)) & any(grepl("Bravo", Item)))
grepl("Alpha|Bravo", Item) else FALSE)
# Case Date Item combiflag
# <int> <chr> <chr> <lgl>
#1 1 2016-03-25 Alpha TRUE
#2 2 2016-03-25 Bravo TRUE
#3 3 2016-03-25 Charlie FALSE
#4 4 2016-03-25 Delta FALSE
#5 5 2016-03-31 Alpha FALSE
#6 6 2016-03-31 Echo FALSE
#7 7 2016-03-31 Falcon FALSE