79448707

Date: 2025-02-18 15:06:52
Score: 1
Natty:
Report link

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"
      )
    ))
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Kitt