I am writing a package with several functions that accept a dataframe object as well as the the dataframe's column names as arguments.
Here is a simplified example:
func = function(df,vars){
head(df[,vars])
}
#column args as strings
func(mtcars,c("mpg","cyl"))
Instead of supplying the column names as strings, I would like the function to accept (and suggest/auto-complete) the column names like in dplyr functions.
#dplyr-style args
func(mtcars, mpg, cyl)
#which doesnt work because mpg and cyl don't exist as objects
I considered using the ...
as function arguments but this would still involve using strings.
Any help would be appreciated.