[R] Which function to use: grep, replace, substr etc.?

syrvn mentor_ at gmx.net
Sun Oct 16 18:35:58 CEST 2011


Hello,

I have a simple question but I don't know which method is best to use for my
problem.

I have the following strings:

str1 <- "My_name_is_peter"
str2 <- "what_is_your_surname_peter"

I would like to apply predefined abbreviations for peter=p and name=n to
both strings
so that the new strings look like the followings:

str1: "My_n_is_p"
str2: "what_is_your_surn_p"

Which method is the best to use for that particular problem?

syrvn

--
View this message in context: http://r.789695.n4.nabble.com/Which-function-to-use-grep-replace-substr-etc-tp3909871p3909871.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list