[R-sig-Geo] Call and Eval function inside R

Michael Sumner mdsumner at gmail.com
Wed Jul 13 09:05:39 CEST 2011


Please don't cross post:

http://stackoverflow.com/questions/6671029/call-and-eval-function-inside-r

This is not a question for R-Sig-Geo at any rate, R-help is a better
candidate and you should consult that mailing list's posting guide.

Cheers, Mike.

On Wed, Jul 13, 2011 at 6:29 AM, Narayani Barve <narayani at ku.edu> wrote:
> Hi All,
>
> I am writing a function where I want to supply a variable which contains a
> condition to be evaluated inside the function. For example, I have a hourval
> variable containing values like 0, 3, 6, 9, 18, 3, 6, 9, 18 0, 3, 18 ... I
> want to select the indices where hourval variable matches to 0, 6.. This 0,
> 6  could change depending upon some other parameters. Basically they are not
> fixed always. So I pass a variable g1 =  call("which", (hourval==0 | hourval
> == 6)). I want this statement to be evaluated in the program. Hence I use
> the statement x1 = eval(g1). Obviously, when I pass the variable g1, that
> time hourval variable is not generated, but it is generated just before the
> eval(g1) statement. I get error,  object 'hourval' not found. Is there any
> other way to solve this problem.
>
> Thanks in advance, any help is appreciated.
>
> Narayani Barve
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsumner at gmail.com



More information about the R-sig-Geo mailing list