Suppose I write such a function in R:
fun1 <- function(x,...,simplify=TRUE,sort=TRUE) {
# do something here ...
}
In the function, ...
is supposed to be a number of expressions that are evaluated in specific environments. However, sometimes it is possible that the expression itself is simplify=FALSE
or sort=FALSE
which are intended for ...
not the arguments of fun1
.
I learned from some packages that the author avoid using potential conflicts between possible named values for ...
and existing argument names. Therefore they write the function in the following manner:
fun1 <- function(.data, ..., .simplify = TRUE, .sort = TRUE) {
# do something here ...
}
It does not solve the problem but avoids many potential conflicts under the assumption that typical data input will not frequently use .data
, .simplify
, and .sort
in the expression.
What is the best practice to solve or walk around this problem?