[英]R manipulate a list of matrices
Been stuck with this for a while! 卡住了一段时间!
How can I manipulate the first list into the second? 如何将第一个列表转换为第二个列表?
list("X" = X, "Y" = Y, ...)
list("X" = c(X,n), "Y" = c(Y,n), ...)
where X and Y are matrices and n is an integer and the lists are of unknown size. 其中X和Y是矩阵,n是整数,列表的大小未知。 Thanks!
谢谢!
If c(X,n)
, which coerces matrix to vector, is what you really want, then 如果将矩阵强制转换为向量的
c(X,n)
是您真正想要的,则
lst <- list(a = matrix(1:4, 2), b = matrix(1:4, 2))
n <- 5
lapply(lst, c, n)
# $a
# [1] 1 2 3 4 5
#
# $b
# [1] 1 2 3 4 5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.