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.dun...@gmail.com> wrote:
> On 31/10/2010 4:47 PM, Wu Gong wrote:
>>
>> Hi Duncan:
>>
>> I'm curious about the environment setting. ?eval says:
>>
>> "If envir is not specified, then the default is parent.frame() (the
>> environment where the call to eval was made). "
>>
>> So what's the difference between set envir=parent.frame() or not?
>
> If you pass parent.frame() as an argument, it will be one level up: it's the
> parent of the function that calls eval.  If you leave it at the default,
> it's the parent of eval, i.e. the function that calls it.
>
> Duncan Murdoch
>
> ______________________________________________
> 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.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics

______________________________________________
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