1
我有一个使用expand.grid()生成的矩阵列表。按列数排序的矩阵排序列表
myarray=matrix(rexp(200),10,3)
list.of.matrices <- apply(expand.grid(rep(list(c(FALSE, TRUE)), ncol(myarray))),
1, function(j)myarray[, j, drop = FALSE])
当我使用的命令
myarray.dim=sapply(myarray, ncol)
我注意到,在顺序,我需要的不是生成的列表。如果可能的话,我想让他们从1列开始到3。
这很棒,它正是我所需要的。你知道为什么这个零列条目生成吗? – nopeva
@ user1228124查看'expand.grid(rep(list(c(FALSE,TRUE)),ncol(myarray)))'的输出。 – Roland
或只是'list.of.mat [命令(sapply(list.of.mat,ncol))]' – flodel