Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
作为一组函数输入的QUOSURE列表_R_Dplyr_Future_Rlang - Fatal编程技术网

作为一组函数输入的QUOSURE列表

作为一组函数输入的QUOSURE列表,r,dplyr,future,rlang,R,Dplyr,Future,Rlang,此问题涉及“使用dplyr编程” 我想把。。。函数的参数,并将每个元素用作相应函数的参数 foo <- function(...){ <some code> } 因此,x,y,z保持被引用状态,直到它们在栏中得到评估 我试过这个: foo <- function(...){ arguments <- quos(...) out <- map(arguments, ~bar(UQ(.))) out } foo您不需要任何软件包匹配。可以使用cal

此问题涉及“使用dplyr编程”

我想把。。。函数的参数,并将每个元素用作相应函数的参数

foo <- function(...){
<some code>
}
因此,
x,y,z
保持被引用状态,直到它们在
栏中得到评估

我试过这个:

foo <- function(...){
  arguments <- quos(...)
  out <- map(arguments, ~bar(UQ(.)))
  out
}

foo您不需要任何软件包<代码>匹配。可以使用call

foo <- function(..., envir = parent.frame()) {
   cl <- match.call()
   cl$envir <- NULL
   cl[[1L]] <- as.name("bar")
   lapply(seq_along(cl)[-1], function(i) eval(cl[c(1L, i)], envir))
}

# test    
bar <- function(...) match.call()
foo(x = 1, y = 2, z = 3)
另一个测试

bar <- function(...) ..1^2
foo(x = 1, y = 2, z = 3)
[[1]]
bar(x = 1)

[[2]]
bar(y = 2)

[[3]]
bar(z = 3)
bar <- function(...) ..1^2
foo(x = 1, y = 2, z = 3)
[[1]]
[1] 1

[[2]]
[1] 4

[[3]]
[1] 9