Use of enquos(...) in function

I'm working on a new package for creating and working with spatial interaction models (SIMs) in R. I'm testing out non-standard evaluation and have found that this function works well:

si_calculate = function(.data, fun, ...) {
  dots = rlang::enquos(...)
  od = dplyr::mutate(od, interaction = fun(!!!dots))

Works well, better than the previous implementation, in terms of allowing use in dplyr pipelines:

si_calculate = function(data, fun, ...) {
  od$interaction = fun(od, ...)

The above are simplified versions of code in this PR: Tidyeval by Robinlovelace · Pull Request #10 · Robinlovelace/si · GitHub

See here for more context:

I've looked at the rlang docs for enquos() and associated vignettes but can find little on best practice for this kind of thing and am wondering if this is a common/effective pattern in NSE? Thanks!

This topic was automatically closed 21 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.