R函数中如何返回多个对象的问题:
You can return a vector, or a list.
你可以返回一个变量或者一个list 点击打开链接
举例:
func <- function() {
...
result <- list(variance=3, sd=sqrt(3))
return(result) # you can omit this
}
if you omit the "return(result)" line, thefunction will return nothing since it ends with an assignment. Furthermore,
explicit use of return() is never needed at the end of a function. The above snippet is correct, but this is enough:
如果函数中省略了return(result)这行,函数将无返回值,上面的是zheng
func <- function() {
...
result <-list(variance=3, sd=sqrt(3))
result
}