以下函数创建一个具有n列作为参数数量的data.frame
functionWithDots <- function(...) {
f1 <- function(x) c(x,x+4)
list <- list(...)
list <- lapply(list, f1)
expand.grid(list)
}
Run Code Online (Sandbox Code Playgroud)
作为functionWithDots(1,2)运行时,预期结果是:
而如果我通过用“ 1:2”替换“(1,2)”来做同样的事情,
functionWithDots(1,2)
Run Code Online (Sandbox Code Playgroud)
结果是
我如何将正确的未连接参数传递给该函数,因为传递时似乎返回不同的结果,比如说,“ 1,2,3”而不是“ c(1,2,3)”?