zjffdu zjffdu - 3 months ago 7
R Question

What does "list(...)" mean in R?

I saw it "list(...)" in some R source code. But I can not execute it in R cosonle. Does anyone know what it means in R.

> list(...)
Error: '...' used in an incorrect context

Answer

Here is an example of how you can use the ellipses to pass arguments along.

my_list_func <- function(...) {
    list(...) # All arguments passed to function are given to 'list'
}
# Call function with various parameters. Returns a list using these params.
my_list_func(a=3, b = list(val = 1:3))
## $a
## [1] 3
## 
## $b
## $b$val
## [1] 1 2 3
Comments