R:矩阵中的错误(0,nrow = N,ncol = n.seq):非数字矩阵范围

时间:2015-07-19 23:35:39

标签: r matrix

library(RMallow)
> dput(rankings)
structure(list(MEMORY1 = c(5.5, 7, 1.5, 6, 4.5, 4.5, 5, 4, 1, 
5.5, 2.5, 4.5, 2.5, 5.5, 4, 1, 4, 5, 2.5, 5.5), MEMORY2 = c(5.5, 
3, 1.5, 6, 4.5, 4.5, 5, 4, 5, 5.5, 6.5, 4.5, 2.5, 5.5, 4, 7, 
8, 5, 6.5, 5.5), MEMORY3 = c(5.5, 3, 4.5, 2, 4.5, 4.5, 5, 4, 
5, 1.5, 6.5, 4.5, 6.5, 5.5, 4, 7, 4, 5, 6.5, 5.5), MEMORY4 = c(1.5, 
3, 4.5, 2, 1, 4.5, 5, 4, 5, 5.5, 2.5, 4.5, 2.5, 1.5, 4, 2, 4, 
5, 2.5, 1.5), MEMORY5 = c(5.5, 3, 4.5, 6, 4.5, 4.5, 5, 1, 5, 
5.5, 6.5, 4.5, 6.5, 5.5, 4, 4, 4, 5, 2.5, 1.5), MEMORY6 = c(5.5, 
7, 7.5, 6, 8, 4.5, 5, 7.5, 5, 5.5, 6.5, 4.5, 6.5, 5.5, 4, 4, 
4, 5, 2.5, 5.5), MEMORY7 = c(1.5, 3, 4.5, 2, 4.5, 4.5, 1, 4, 
5, 1.5, 2.5, 4.5, 6.5, 1.5, 4, 7, 4, 1, 6.5, 5.5), MEMORY8 = c(5.5, 
7, 7.5, 6, 4.5, 4.5, 5, 7.5, 5, 5.5, 2.5, 4.5, 2.5, 5.5, 8, 4, 
4, 5, 6.5, 5.5)), .Names = c("MEMORY1", "MEMORY2", "MEMORY3", 
"MEMORY4", "MEMORY5", "MEMORY6", "MEMORY7", "MEMORY8"), row.names = c(NA, 
20L), class = "data.frame")

abils = ncol(rankings)
R = Rgen(2, hyp = NULL, abils)
AllKendall(ranking, R)

当我运行上面的代码时,我收到一条错误消息Error in matrix(0, nrow = N, ncol = n.seq) : non-numeric matrix extent。我读了一些其他相关的帖子,似乎问题是nrow = N不是数字。是什么导致了这种情况发生,我该如何解决?

1 个答案:

答案 0 :(得分:0)

如果你看一下?AllKendall中的例子,你的“序列集”似乎应该是一个矩阵(看看他们有一个排名列表然后他们rbind他们在一起? )

为此,请尝试

AllKendall(do.call(rbind, R), do.call(rbind, rankings))
# for some reason if you put it the other way round there is an error

结果是一个矩阵,output[i, j]i中序列Rj中序列rankings的距离。