I would like to find a way to identify if the dots are not used, so that I can make a function that provides different default behaviour where the dots are not used.
Below is an example to illustrate the problem. How could I identify within the function if the user has not provided any arguments to ... and if so instead just return all columns of the dataset instead of nothing?
Here is a suggestion (I have a feeling that there is a more elegant solution):
library(dplyr)
select2 <- function(data, ...) {
tryCatch(expr = {
str(...) #Do something that fails if function is called with no ...-arguments
data%>%
select(...)
},
error=function(e){
data
} )
}
select2(iris)