【发布时间】:2020-10-03 12:34:28
【问题描述】:
我最近考虑了函数的... 参数,并注意到R 不允许检查对象的类。
f <- function(...) {
class(...)
}
f(1, 2, 3)
## Error in class(...) : 3 arguments passed to 'class' which requires 1
现在加上报价
“要理解 R 中的计算,有两个口号很有帮助:
• 存在的一切都是对象。 • 发生的一切都是 函数调用。”
——约翰·钱伯斯
我在想:... 是什么对象?
【问题讨论】:
-
Section 1.5.2 of the R Internals manual 可能会有所帮助。它们是一种特殊类型的“pairlist”。 Section 1.1.1 告诉我们“配对列表在 R 级别很少见,但例如用于参数列表。”配对列表的其他内容是语言对象,例如公式。
标签: r class optional-parameters typeof