【发布时间】:2021-12-22 11:35:46
【问题描述】:
我有一个值列表作为输出:
[,1] [,2] [,3]
ATE_true numeric,1000 numeric,1000 numeric,1000
ate_now numeric,1000 numeric,1000 numeric,1000
ate_truew numeric,1000 numeric,1000 numeric,1000
ate_estw numeric,1000 numeric,1000 numeric,1000
ci_w numeric,1000 numeric,1000 numeric,1000
我想获得每 1000 个值的平均值,即 mean(ATE_true[,1], ATE_true[,2]... 等等。因此使用了 apply 函数
apply(output,1:2,mean)
但我得到返回 NA 值并出现错误: 在 mean.default(newX[, i], ...) 中: 参数不是数字或逻辑:返回 NA
我理解输出是列表格式,它被认为是非数字的,但是我该如何解决这个问题?
我想要的输出:
[,1] [,2] [,3]
ATE_true 0.98 0.94 0.97
ate_now 0.86 0.85 0.88
ate_truew 0.83 0.87 0.85
ate_estw 0.86 0.89 0.90
ci_w 0.92 0.91 0.95
【问题讨论】: