0
考虑到与不同的列数的矩阵列表:如何将函数应用于列表中的每个元素,在特定的列范围内?
set.seed(123)
a <- replicate(5, matrix(runif(25*30), ncol=25) , simplify=FALSE)
b <- replicate(5, matrix(runif(30*30), ncol=30) , simplify=FALSE)
list.of.matrices <- c(a,b)
如何申请函数式编程原则(即使用purrr包)到列的具体范围(即第8行,从第二到列的末尾)?
map(list.of.matrices[8, 2:ncol(list.of.matrices)], mean)
以上的回报:
Error in 2:ncol(list.of.matrices) : argument of length 0