首页 > 解决方案 > R中的包装函数

问题描述

以下代码由五个函数组成。运行wrapTables时,只输出t表?如何解决每个表格的输出,例如“卡方表”,然后是卡方概率表?谢谢。

毫米

wrapTables <- function() {
chistable()
ftableb()
normtab()
poissontable2()
ttable()
}

wrapTables() 

标签: rfunction

解决方案


考虑返回一个包含每个函数输出的命名列表:

wrapTables <- function() { 
   list(Chi_Square_Table = chistable(),
        F_Table = ftable(),
        Norm_Table = normtab(),
        Poisson_Table = poissontable2(),
        T_table = ttable()
   )
}

然后任何分配给此函数的对象都将具有相应命名的元素:

output <- wrapTables()

output$Chi_SquareTable
output$F_Table
output$Norm_Table
...

或全部一起但以列表格式:

output

推荐阅读