user4704857
user4704857

Reputation: 469

Removing a substring including parentheses and dash from other strings in R

I would like to remove substring " - Homo sapiens (human)" from a list of strings using gsub(.) function. I think I need to convert it to a regular expression But I do not know how to do it. I appreciate if anyone could help me.

Thanks.

Upvotes: 0

Views: 119

Answers (1)

lukeA
lukeA

Reputation: 54237

Try

gsub(" - Homo sapiens (human)", "", x, fixed = TRUE)

, where x contains your character vector.

Upvotes: 1

Related Questions