How to avoid creating quosures of quosures?

I'm writing some functions that defuse their arguments with enquo(). The trouble is that some of these functions call others, so they end up passing quosures to enquo(), thus creating quosures of quosures. Is there some convenient way to avoid this? Does rlang have facilities for creating quosures idempotently?

Before enquo you could test with something like:


Or I think this will work fine?


         .x <- rlang::enquo(.x)



1 Like

Calling is_quosure() forces the quosure to evaluate, so that approach does not work.

Using UQ() or !! works perfectly, albeit only if you use it directly inside the function arguments. So for example you could not do .x <- UQ(enquo(.x)) at the top of the example function. Still it looks like that's the best way to achieve this. Thanks Stuart!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.