我有以下数据集:
0101110
1010000
1010011
0101010
1000101
并希望将其序列化。 当我读到一个call seriate函数时,就像这样:
matr <- read.table(...)
ser <- seriate(as.matrix(matr))
我收到错误:
Error in seriate.default(max(criterion) - criterion, method = "TSP", control = control) :
seriate not implemented for class 'numeric'.
In addition: Warning message:
In max(criterion) : no non-missing arguments to max; returning -Inf
有什么问题?我不明白。我也阅读了文档而没有找到任何内容
答案 0 :(得分:1)
您的阅读方式似乎有问题。以下工作正常:
> library(seriation)
> m <- matrix(c(0,1,0,1,1,1,0,
+ 1,0,1,0,0,0,0,
+ 1,0,1,0,0,1,1,
+ 0,1,0,1,0,1,0,
+ 1,0,0,0,1,0,1), nrow=5, byrow=T )
> m
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 0 1 0 1 1 1 0
[2,] 1 0 1 0 0 0 0
[3,] 1 0 1 0 0 1 1
[4,] 0 1 0 1 0 1 0
[5,] 1 0 0 0 1 0 1
>
> seriate(m)
object of class ‘ser_permutation’, ‘list’
contains permutation vectors for 2-mode data
vector length seriation method
1 5 BEA_TSP
2 7 BEA_TSP
但是,如果我将矩阵转换为数字,我得到的错误与你得到的相同,这似乎表明你的矩阵是一个数字,并且连续反应直接转换为矩阵。换句话说,确保输入正确。
> m <- as.numeric(m)
> seriate(as.matrix(m))
Error in seriate.default(max(criterion) - criterion, method = "TSP", control = control) :
seriate not implemented for class 'numeric'.
In addition: Warning message:
In max(criterion) : no non-missing arguments to max; returning -Inf