Skip to content

transfer string to expression

1 message · Bert Gunter

#
If it's not already clear, perhaps this slight variation might help
explain what's happening:

b0<-1
b1<-1
x<-1
str2expr<-function(y){eval(parse(text=y))}  ## Note change from "x" to "y" here
test1<-"b0+b1*sqrt(x)"
str2expr(test1)

Cheers,
Bert

On Sun, Oct 31, 2010 at 1:58 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote: