The R language has a nifty feature for defining functions that can take a variable number of arguments. For example, the function data.frame
takes any number of
Just to add to Shane and Dirk's responses: it is interesting to compare
get_list_from_ellipsis1 <- function(...)
{
list(...)
}
get_list_from_ellipsis1(a = 1:10, b = 2:20) # returns a list of integer vectors
$a
[1] 1 2 3 4 5 6 7 8 9 10
$b
[1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
with
get_list_from_ellipsis2 <- function(...)
{
as.list(substitute(list(...)))[-1L]
}
get_list_from_ellipsis2(a = 1:10, b = 2:20) # returns a list of calls
$a
1:10
$b
2:20
As it stands, either version appears suitable for your purposes in my_ellipsis_function
, though the first is clearly simpler.