我对 R 很陌生,我发现一个向量操作令人沮丧:
我只想在使用 sapply 时知道列表中当前元素的索引,比如说:打印索引,但我所有的试验都不起作用,例如:
> test <- sapply(my.list.of.matrices,
function(x) print(which(my.list.of.matrices == x)))
Error in which(my.list.of.matrices == x) :
(list) object cannot be coerced to type 'logical'
In addition: Warning message:
In my.list.of.matrices == x :
longer object length is not a multiple of shorter object length