[R] Avoid using eval in a neat way

2014-02-01 Thread Hai Qian
I know using eval is not optimal and maybe bad, but how to avoid using eval in the following example func1 - function(dat, eval.this) { eval(parse(text = paste0(with(dat, , eval.this, } dat - data.frame(x = 1:2, y = 2:3) func1(dat, x*2+y) func1(dat, sin(x)*cos(y)) Here eval.this is a

Re: [R] Avoid using eval in a neat way

2014-02-01 Thread Ista Zahn
This has been discussed extensively, on this list as well as elsewhere. I suggest doing a web search, read up on the issue, and post back here only if you have specific questions that are not answered already. Best, Ista On Sat, Feb 1, 2014 at 11:40 AM, Hai Qian hq...@gopivotal.com wrote: I

Re: [R] Avoid using eval in a neat way

2014-02-01 Thread Hai Qian
I have been searching around for some time, but with no luck for this particular problem. -- *Pivotal http://www.gopivotal.com/* A new platform for a new era On Sat, Feb 1, 2014 at 9:02 AM, Ista Zahn istaz...@gmail.com wrote: This has been discussed extensively, on this list as well as

Re: [R] Avoid using eval in a neat way

2014-02-01 Thread Jeff Newmiller
You have set up your criteria for success to be that your user has full freedom to specify code in strings to evaluate. Then you ask how to achieve this goal without evaluating that code. Are you thinking objectively at all about your question? The advice to not use eval has a number of

Re: [R] Avoid using eval in a neat way

2014-02-01 Thread Duncan Murdoch
On 14-02-01 11:40 AM, Hai Qian wrote: I know using eval is not optimal and maybe bad, but how to avoid using eval in the following example func1 - function(dat, eval.this) { eval(parse(text = paste0(with(dat, , eval.this, } dat - data.frame(x = 1:2, y = 2:3) func1(dat, x*2+y)

Re: [R] Avoid using eval in a neat way

2014-02-01 Thread Hai Qian
Hi Jeff, Your answer is good. It makes me think that maybe I should revise some of my designs. Now I know that it is impossible to do this under my settings. Thanks On Sat, Feb 1, 2014 at 9:55 AM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote: You have set up your criteria for success to be

Re: [R] Avoid using eval in a neat way

2014-02-01 Thread Gabor Grothendieck
On Sat, Feb 1, 2014 at 11:40 AM, Hai Qian hq...@gopivotal.com wrote: I know using eval is not optimal and maybe bad, but how to avoid using eval in the following example func1 - function(dat, eval.this) { eval(parse(text = paste0(with(dat, , eval.this, } dat - data.frame(x = 1:2,