Thanks @maelle Your suggestions don't work for the kind of model object I am working with
Your first suggestion returns NA like it does for 1, so that point in the code get_expr isn't returning a name.
For your second example I wasn't 100% sure where you intended to insert/substitute the call_args() bit, but the attempts I tried always return
Error in `rlang::call_args()`:
! `call` must be a defused call, not a symbol.
I can get closer by doing
foo <- function(x) {
expr <- rlang::enquo(x)
expr
}
r$> foo(m_gamm$gam)
<quosure>
expr: ^m_gamm$gam
env: global
where the quosure seems to have captured the expression I want (although it's prepended ^ for some reason that I don't understand). From there I got to
foo <- function(x) {
expr <- rlang::enquo(x)
rlang::expr_text(expr)
}
which gets me very close but now I have a prepended ~ (!)
r$> foo(m_gamm$gam)
[1] "~m_gamm$gam"
I could easily get rid of the "~" part of this string, but that seems convoluted compared to deparse(substitute(arg)) which is what I have used for the time being in my package code.
But I'm getting closer: thanks 