R 系列 -> 在 max(criterion) 中:max 没有非缺失参数;返回-Inf

问题描述 投票:0回答:1

我有以下数据集:

0101110
1010000
1010011
0101010
1000101

并想将其序列化。 当我读到它时,它是一个调用串行函数,如下所示:

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

问题是什么?我不明白。我也阅读了文档,但什么也没发现

r matrix seriation
1个回答
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
© www.soinside.com 2019 - 2024. All rights reserved.