I need to write a function with a function argument, which will slightly modify the function and return the modified function.
what I have so far is
discriminant.functions <- function(priordist1,PC1)
{
g1 <- PC1*match.fun(priordist1)
return(g1)
}
but it doesn't work - i get the following error message when I call the function:
discriminant.functions(function(x1,x2) 36*x1*x2*(1-x1)*(1-x2),0.5)
Error in PC1 * match.fun(priordist1) :
non-numeric argument to binary operator
I am not very experienced with R and so I don't know if there are obvious ways to do this, it really seems like it should be very simple. Any help appreciated, thank you very much!