[R] gsub/strsplit with multiple patterns/splits

mdvaan mathijsdevaan at gmail.com
Thu May 31 00:05:12 CEST 2012


Hi,

I have a vector like this:

DF <- c("Aetna, Inc.", "Alexander's Inc.", "Allegheny Energy, Inc")

For each element in the vector I would like to remove the "incorporated"
info, so that my vector looks like this:

DF <- c("Aetna", "Alexander's", "Allegheny Energy")

That means that I have to strip:

strip <- c(", Inc.", " Inc.", ", Inc")

How do I pass multiple patterns/splits to gsub/strsplit?

Thanks!

Math


--
View this message in context: http://r.789695.n4.nabble.com/gsub-strsplit-with-multiple-patterns-splits-tp4631873.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list