Displaying 1 result from an estimated 1 matches for "apply_some_funct".
2010 Sep 22
3
Passing a function as a parameter...
R-helpers:
If I want to pass a character name of a function TO a function, and then
have that function executed, how would I do this? I want
an arbitrary version of the following, where any function can be used (e.g.
I don't want the if-then statement here):
apply_some_function <- function(data,function_name)
{
if(function_name=="mean")
{
return(mean(data))
}
if(function_name=="min")
{
return(min(data))
}
}
apply_some_function(1:10,"mean")
apply_some_function(1:10,"min")
Basically, I want the character name of the functio...