Copy String of Adjacent Cell if Cell Contains Specific String

Solution for Copy String of Adjacent Cell if Cell Contains Specific String
is Given Below:

How do you copy the string of an adjacent cell if a cell contains a specific string?

A simplified version of my data frame looks like this:

df <- data.frame(
  BT1Sp = c("Pine","White Oak"),
  BT1Diam = c(20,15),
  BT2Sp = c("do","Black Oak"),
  BT2Diam = c(22,12)
)

T.Sps <- c("Pine|White Oak|Black Oak")

How can I replace the string in the BT2Sp column with the string in the BT1Sp column, if the string in BT2Sp is ‘do’?

With across:

library(dplyr)
df %>% mutate(across(BT2Sp,~ifelse(.=="do",BT1Sp,.)))

We may create a logical expression with str_detect in case_when to do the replacement

library(stringr)
library(dplyr)
df %>% 
   mutate(BT2Sp = case_when(str_detect(BT1Sp, T.Sps) ~ BT1Sp, TRUE ~ BT2Sp))