gpt4 book ai didi

r - 按元素排列的矩阵列表的平均值

转载 作者:行者123 更新时间:2023-12-04 11:25:57 26 4
gpt4 key购买 nike

<分区>

我有一个矩阵列表:

 .list <- list(matrix(1:25, ncol = 5), matrix(11:35, ncol = 5))

我想使用 Reduce 方法来查找列表中矩阵的逐元素均值。

换句话说,我正在寻找以下结果:

 res = matrix(6:30, ncol = 5)

我尝试了以下方法:

 res = Reduce(mean, .list)

但是我得到一个错误:

Error in mean.default(init, x[[i]]) : 
'trim' must be numeric of length one

请注意,矩阵的元素可以是NA。任何帮助,将不胜感激!谢谢!!

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com