Skip to content

I modified my question in "search and convert string function "

2 messages · peng shen, Gabor Grothendieck

#
Hi ,all R-helper!
I modified my  question  in "search and convert string function".
I want to do this kind of operation In R enviroment :
For example :
R <- 4
testString <- "I love %R%"
then search this testString, when find beginning and end symbol"%",get a new 
substring "%R%".
then get rid of symbole"%",replace string"R" by R(numeric )
So the final string is "I love 4"

How can I implement? if there is not this kind of function ,how can I write 
function in C and implement in R.
Thanks advance

Michael
#
peng shen <michael_shen <at> hotmail.com> writes:

: 
: Hi ,all R-helper!
: I modified my  question  in "search and convert string function".
: I want to do this kind of operation In R enviroment :
: For example :
: R <- 4
: testString <- "I love %R%"
: then search this testString, when find beginning and end symbol"%",get a new 
: substring "%R%".
: then get rid of symbole"%",replace string"R" by R(numeric )
: So the final string is "I love 4"
: 
: How can I implement? if there is not this kind of function ,how can I write 
: function in C and implement in R.
: Thanks advance
: 

The function in my response to your original post can already do that:

R> interp("I love %R%", pre = "%", post = "%")
[1] "I love 4"