You can do something like this
library(tidyverse)
sample_df <- data.frame(
stringsAsFactors = FALSE,
original_column = c(
"clone 9_+b_004.fcs/Single cells/red vs. green",
"clone 9_+T_004.fcs/Single cells/red vs. green",
"clone 10_+b_004.fcs/Single cells/red vs. green"
)
)
sample_df %>%
separate(original_column,
into = c("clone", "added_compound", "other_column"),
sep = "_") %>%
mutate(added_compound = case_when(
added_compound == "+b" ~ "TGFb",
added_compound == "+T" ~ "Tamoxifen"
))
#> clone added_compound other_column
#> 1 clone 9 TGFb 004.fcs/Single cells/red vs. green
#> 2 clone 9 Tamoxifen 004.fcs/Single cells/red vs. green
#> 3 clone 10 TGFb 004.fcs/Single cells/red vs. green
Created on 2020-03-08 by the reprex package (v0.3.0.9001)
If this doesn't solve your issue, please provide a proper REPRoducible EXample (reprex) illustrating your issue.