更新时间:2023-02-10 15:43:15
因此,通常来说,如何将两个列表的对应成员相乘?假设值的矩阵在list1
中,而值0/1的矩阵在list2
中,则使用lapply的方法之一
So generically, how do you multiply corresponding members of two lists? Suppose the matrices with values are in list1
and those with 0/1 are in list2
, then one way to do it is with lapply
answer <- lapply(seq_along(list1),FUN=function(i) list1[[i]]*list2[[i]])
您得到的矩阵将是answer
的元素.
Your resulting matrices will be the elements of answer
.