hora
hora

Reputation: 855

How to sub-string elements of a vector in R

I have a vector of strings, all containing a common symbol lets say "*". I need to delete the * and all characters after that for all vector elements. For example: In abcd*123 I need to have abcd. The number of characters, before and after * are various. Thanks for the help.

Upvotes: 0

Views: 709

Answers (1)

Rorschach
Rorschach

Reputation: 32416

out <- gsub("\\*.*", "", yourVector)

Upvotes: 2

Related Questions