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