match.fun package:base R Documentation _F_u_n_c_t_i_o_n _V_e_r_i_f_i_c_a_t_i_o_n _f_o_r "_F_u_n_c_t_i_o_n _V_a_r_i_a_b_l_e_s" _D_e_s_c_r_i_p_t_i_o_n: When called inside functions that take a function as argument, extract the desired function object while avoiding undesired matching to objects of other types. _U_s_a_g_e: match.fun(FUN, descend = TRUE) _A_r_g_u_m_e_n_t_s: FUN: item to match as function: a function, symbol or character string. See 'Details'. descend: logical; control whether to search past non-function objects. _D_e_t_a_i_l_s: 'match.fun' is not intended to be used at the top level since it will perform matching in the _parent_ of the caller. If 'FUN' is a function, it is returned. If it is a symbol (for example, enclosed in backquotes) or a character vector of length one, it will be looked up using 'get' in the environment of the parent of the caller. If it is of any other mode, it is attempted first to get the argument to the caller as a symbol (using 'substitute' twice), and if that fails, an error is declared. If 'descend = TRUE', 'match.fun' will look past non-function objects with the given name; otherwise if 'FUN' points to a non-function object then an error is generated. This is used in base functions such as 'apply', 'lapply', 'outer', and 'sweep'. _V_a_l_u_e: A function matching 'FUN' or an error is generated. _B_u_g_s: The 'descend' argument is a bit of misnomer and probably not actually needed by anything. It may go away in the future. It is impossible to fully foolproof this. If one 'attach'es a list or data frame containing a length-one character vector with the same name as a function, it may be used (although name spaces will help). _A_u_t_h_o_r(_s): Peter Dalgaard and Robert Gentleman, based on an earlier version by Jonathan Rougier. _S_e_e _A_l_s_o: 'match.arg', 'get' _E_x_a_m_p_l_e_s: # Same as get("*"): match.fun("*") # Overwrite outer with a vector outer <- 1:5 ## Not run: match.fun(outer, descend = FALSE) #-> Error: not a function ## End(Not run) match.fun(outer) # finds it anyway is.function(match.fun("outer")) # as well