On 22.11.2011 19:23, Erin Hodgess wrote:
Dear R People:

Hope you're having a nice day.

Here is a character vector:

yz
[1] "pexp(3.2,rate=1)"
str(yz)
  chr "pexp(3.2,rate=1)"

And I would like to evaluate that vector.

I tried:
eval(as.expression(yz))
[1] "pexp(3.2,rate=1)"


But that doesn't work.

Any suggestions would be most welcome.  I have a feeling that it's
quite simple and that I'm having a forest vs. trees issue.


Erin,

you need to parse() the text before eval()uating it. In most cases, the original problem is why you got the text and not already something that is a language object.

Best,
Uwe



Thanks,
Erin



______________________________________________
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