[R] gsub to manipulate characters

syrvn mentor_ at gmx.net
Fri Feb 24 12:48:53 CET 2012


Hello,

from a vector of strings I want to delete everything after the _

> v <- c("AAA_BB", "FF_MM")
> gsub("_*", "", v)
[1] "AAABB" "FFMM" 


but should be
[1] "AAA" "FF" 


Why does * not work? Even perl=TRUE does not give me the right result

Man thanks!


--
View this message in context: http://r.789695.n4.nabble.com/gsub-to-manipulate-characters-tp4416939p4416939.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list