该函数看起来像:
function(input, FUN, output) {
output <- FUN(input)
return(input)
}
Run Code Online (Sandbox Code Playgroud)
其中output是要创建的对象的不带引号的名称.
让我们跳过这可能是一个坏主意的部分:这种事情有可能吗?你会怎么做呢?
清洁代码只会返回它.
但你有其他选择:
<<-运营商assign()您可以列出要分配的环境的功能这是一个简单的例子:
R> foo <- function(x=21) { y <<- 2*x; return(3*x) }
R> foo(10)
[1] 30
R> y
[1] 20
R>
Run Code Online (Sandbox Code Playgroud)