embrace operator {{ and data masking in interactive sessions

In a package I'm developing, I'm allowing the user to select column names, in a way that is functionally similar to the example included in the documentation on data mask programming.

Let's say that I have a function such as:

my_summarise <- function(data, var) {
  data |> dplyr::summarise({{ var }})
}

In the real world, the function is obviously more complex, so I troubleshoot it in an interactive session.

Is there some easy way to work with this in a usual interactive R session, passing to var the desired value? E.g. , testing this function as if the user war running the following function?

my_summarise(data, var = string)

and run the code:

  data |> dplyr::summarise({{ var }})

without getting any error?

I appreciate that more formal debugging approaches, breakpoints, etc., would probably be more robust, but for some quick checks more informal solutions and testing in a plain R session still feel easier to me.

Any suggestions welcome? If you feel I shouldn't really be trying to work with it this way, or you have suggestions for a better workflows, I'm all happy to read your thoughts.

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