Hello,

Try the following.

1)
pattern <- "response."
m <- regexpr(pattern, ex) #gregexpr to get all "response"
regmatches(ex, m)

2)
gsub("\\$", "\\.", ex)

Hope this helps,

Rui Barradas
Em 16-09-2012 15:35, Özgür Asar escreveu:
Dear all,

I want to manipulate a character string such as

ex<-"cbind(data$response1,data$response2)"

in R in two ways:

1) extracting the "response1" portion of ex
2) replacing "$" with "."

I am wondering that is it possible efficiently doing these in R?

Best

Ozgur



--
View this message in context: 
http://r.789695.n4.nabble.com/two-questions-about-character-manipulation-tp4643292.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to