I think this is xy problem. With example data above and expected output, try the following code:
> df
Column1 Column2 Column3
1 gene=LOC11 product=A partial=true
2 gene=LOC11 product=A partial=true
3 gene=LOC22 product=B partial=true
4 gene=LOC33 product=C partial=true
5 gbkey=CDS gene=LOC44 product=D
6 gbkey=CDS gene=LOC55 product=E
7 gbkey=CDS gene=LOC66 product=F
> library(dplyr)
If you want old columns to be edited:
> df %>%
+ select(1,2) %>%
+ mutate(across(.cols = everything(), ~ifelse(grepl("gene",.), .,"NA")))
Column1 Column2
1 gene=LOC11 NA
2 gene=LOC11 NA
3 gene=LOC22 NA
4 gene=LOC33 NA
5 NA gene=LOC44
6 NA gene=LOC55
7 NA gene=LOC66
if you want new columns to be created:
> df %>%
+ select(1,2) %>%
+ mutate(across(.cols = everything(),
+ ~ifelse(grepl("gene",.), .,"NA"),
+ .names = "new_{col}" ))
Column1 Column2 new_Column1 new_Column2
1 gene=LOC11 product=A gene=LOC11 NA
2 gene=LOC11 product=A gene=LOC11 NA
3 gene=LOC22 product=B gene=LOC22 NA
4 gene=LOC33 product=C gene=LOC33 NA
5 gbkey=CDS gene=LOC44 NA gene=LOC44
6 gbkey=CDS gene=LOC55 NA gene=LOC55
7 gbkey=CDS gene=LOC66 NA gene=LOC66
Post is confusing and TL;DR. Please post expected output.
OP, from what I gather, you seem to be on the right track with grep and mutate to manipulate the values, but cpad0112 is correct, your question is not clear. If you can create a df with the values that you currently have (and copy the code to create it here), and then show what you want as output, then you will get a better response.
Thank you, and sorry for the confusion, I have now added the dataset and the expected output.