This is one way to do it.

a = 1
b = 2
c = parse(text = "log(a + b)")
eval(c)

Hope this helps.

Cheers,

On 27/11/2011 11:16 a.m., Victor wrote:
I would like to make a string executable, e.g,

s<- "ln(a+b)"
a<-1
b<-2

???? execute string s to obtain ln(a+b) ????

How can I make it?

Ciao fron Rome
Vittorio

______________________________________________
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