I was able to figure it out!! For those who experience the same problems, using the dplyr
and stringr
packages provide the functions case_when
and str_detect
. It would look something like this:
G14 %>% mutate(Behavioral.category =(
case_when(
str_detect(Behavior, "slow approach|fin raise|fast approach|bite") ~ "aggressive",
str_detect(Behavior, "flee|avoid|tail quiver") ~ "submissive",
str_detect(Behavior, "bump|join") ~ "affiliative"
)
))