粘贴中"崩溃"的缩写?

use*_*178 17 r argument-matching

使用命令paste在R,我想用两个参数sepcollapse,但不能缩写collapsecoll,甚至collaps.然而对于其他功能,部分缩写起作用.

没有其他参数可以开始崩溃coll,这会干扰部分参数匹配.

为什么我必须在调用paste时键入整个参数名称,当我不需要其他函数时?

Ari*_*man 22

我相信它是...in paste会导致你必须使用精确的参数匹配.具体而言,这样的事实,collapse...参数列表.

示范:

f1 <- function(x, collapse) cat("collapse",collapse)
f2 <- function(..., collapse) cat("collapse",collapse)
f3 <- function(collapse, ...) cat("collapse",collapse)

> f1(c="test",1)
collapse test
> f2(1,c="test")
Error in base::cat(...) : argument "collapse" is missing, with no default
> f2(1,collapse="test")
collapse test
> f3(c="test",1)
collapse test
Run Code Online (Sandbox Code Playgroud)

  • 它在[R语言定义]的[第4.3.2节参数匹配](http://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching)中有记录(http:// cran 1,1'- project.org/DOC /手册/ R-lang.html). (7认同)