Friends,

I'm trying to pass an equation as an argument to a function. The idea is as follows. Let us say i write an independent function 

Ideal Situation:

ifunc <- function(x)
{
return((x*x)-2)
}

mainfunc <- function(a,b)
{
evala <- ifunc(a)
evalb <- ifunc(b)
if (evala>evalb){return(evala)}
else
return(evalb)
}

Now I want to try and write this entire program in a single function with the user specifying the equation as an argument to the function. 

myfunc <- function(a, b, eqn)
{
    func1 <- function (x) ??????????????????
        {
            return(eqn in terms of x)  ??????????????????
       }

Further arguments to check

The ???????? imply that this does not seem to be correct. The idea is how to assign the equation expression from the main equation into the inner function. Is there anyway to do that within this set up?
 

Thanks in advance
Regards

Anup

       
---------------------------------

	[[alternative HTML version deleted]]

