dot-dot-dot
or ...
is called ellipse .
minha_funcao_com_elipse <- function(...) {
input_list <- list(...)
input_list
}
See the result of this function:
> minha_funcao_com_elipse(a = 1, b= 2, c= 3)
$a
[1] 1
$b
[1] 2
$c
[1] 3
Note that the input_list <- list(...)
command creates a list of all the parameters that were passed within the ellipse .
Since input_list
is a common list of R, it's easy to access its elements. The c
function, for example could be imitated as follows:
> c2 <- function(...) {
+ unlist(list(...))
+ }
> c2(a = 1, b= 2, c= 3, 5, 6)
a b c
1 2 3 5 6
It pays to read this SO response . Another good reference is Advanced R in session ...
.