[R] evaluation question
Uwe Ligges
ligges at statistik.tu-dortmund.de
Tue Nov 22 19:36:01 CET 2011
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
>
>
More information about the R-help
mailing list