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:
And found no use of inherits with 'formula' alone.
inherits
'formula'
Your function looks straightforward enough, you should keep it in a utils.R file perhaps
utils.R
Thanks! This made me discover inherits_any which is a nice improvement already :
inherits_any
inherits_any(f, c("function","formula"))
You also have in rlang
is_function
is_formula
is_formulaish
is_lambda
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.