is there an existing function to test :
is.function(f) || inherits(f,"formula")
I tend to use this expression or to define my own when I need it too much but maybe it exists already in rlang ?
is there an existing function to test :
is.function(f) || inherits(f,"formula")
I tend to use this expression or to define my own when I need it too much but maybe it exists already in rlang ?
I searched here:
https://github.com/r-lib/rlang/search?l=R&q="inherits"
And found no use of inherits with 'formula' alone.
Your function looks straightforward enough, you should keep it in a utils.R file perhaps ![]()
Thanks! This made me discover inherits_any which is a nice improvement already :
inherits_any(f, c("function","formula"))
You also have in rlang
is_functionis_formulais_formulaishis_lambda (to test if result of as_function)those can be useful for such tests and better to just test for classes.
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.