I do not understand the cost-benefit of NSE (non-standard evaluation) in R for programming. I can see why NSE may be useful for interactive R, but for programming -- i.e. writing reusable scripts and functions -- my experience is that it mainly adds ambiguity, confusion, and hours of debugging, just to save a few user keystrokes.
In almost every case I've seen, including those throughout Advanced R, NSE seems to be avoidable by adding a few more:
df$xordf[[x]]- "quotes"
- explicit and/or inline functions
do.call
with obvious benefits re. unambiguity
Can someone provide some convincing examples of when / why NSE is useful for programming in R?
Related post about the undocumented dangers of NSE.
I don't know wether there is an absolutely convincing example of unavoidable NSE code, in the terms you're describing (ultimately it is personal opinion) but I'm going to cite the vignette "programming on data.table" of
data.tableone of the most used R packages:So some of the main benefits of NSE is improved readability and maintainability and not only keystroke saving. Also, while you can go sometimes into not-easy-to-debug code, it is also true that the no NSE approach is also prone to errors.
Here the vignette online: https://rdatatable.gitlab.io/data.table/articles/datatable-programming.html
Here the source permalink: https://github.com/Rdatatable/data.table/blob/88039186915028ab3c93ccfd8e22c0d1c3534b1a/vignettes/datatable-programming.Rmd