Re: [R] transfer string to expression

2010-11-01 Thread 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

[R] transfer string to expression

2010-10-31 Thread Yilong Zhang
Dear all: when I use parse() there is some problems. Below is an example: b0-1 b1-1 x-1 str2expr-function(x){eval(parse(text=x))} test1-b0+b1*sqrt(x) test2-b0+b1 str2expr(test1) str2expr(test2) it can work well for test2 but not for test1. Could you tell me how to fix this problem or is there

Re: [R] transfer string to expression

2010-10-31 Thread Duncan Murdoch
On 31/10/2010 3:22 PM, Yilong Zhang wrote: Dear all: when I use parse() there is some problems. Below is an example: b0-1 b1-1 x-1 str2expr-function(x){eval(parse(text=x))} test1-b0+b1*sqrt(x) test2-b0+b1 str2expr(test1) str2expr(test2) it can work well for test2 but not for test1. Could you

Re: [R] transfer string to expression

2010-10-31 Thread David Winsemius
On Oct 31, 2010, at 3:22 PM, Yilong Zhang wrote: Dear all: when I use parse() there is some problems. Below is an example: b0-1 b1-1 x-1 str2expr-function(x){eval(parse(text=x))} test1-b0+b1*sqrt(x) test2-b0+b1 str2expr(test1) str2expr(test2) I don't think the scoping rules are up to the

Re: [R] transfer string to expression

2010-10-31 Thread Wu Gong
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? Thank you. Wu - A R learner. -- View

Re: [R] transfer string to expression

2010-10-31 Thread Duncan Murdoch
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