“列表(...)”在R中的含义是什么?

时间:2016-08-18 05:27:13

标签: r

我在一些R源代码中看到它“list(...)”。但我无法在R cosonle中执行它。有谁知道它在R中意味着什么。

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

1 个答案:

答案 0 :(得分:3)

以下是如何使用省略号传递参数的示例。

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