I believe the solution is to use the .data pronoun imported from rlang with @importFrom rlang .data.
From the dplyr Programming vignette:
We can fix that ambiguity by being more explicit and using the .data pronoun. This will throw an informative error if the variable doesn’t exist:
mutate_y <- function(df) {
mutate(df, y = .data$a + .data$x)
}
mutate_y(df1)
#> Column `a` not found in `.data`
If this function is in a package, using .data also prevents R CMD check from giving a NOTE about undefined global variables (provided that you’ve also imported rlang::.data with @importFrom rlang .data ).