0
我在一些R源代碼中看到了「list(...)」。但是我不能在R cosonle中執行它。有沒有人知道它在R中意味着什麼。R中的「list(...)」是什麼意思?
> list(...)
Error: '...' used in an incorrect context
我在一些R源代碼中看到了「list(...)」。但是我不能在R cosonle中執行它。有沒有人知道它在R中意味着什麼。R中的「list(...)」是什麼意思?
> list(...)
Error: '...' used in an incorrect context
這裏是一個如何使用橢圓來傳遞參數的例子。
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
橢圓是一個語法元素,用於引用從調用函數傳遞的參數。他們引用任意參數,表示調用函數的用戶將在某個時刻提供。在這種情況下,用戶將提供一些對象給可能命名的列表函數。 – shayaa
考慮'foo < - 函數(...)列表(...); foo(1:3,5:9)' – shayaa