R skmeans包——这个错误来自哪里:“缺少TRUE/FALSE所需的值”

时间:2023-01-12 22:29:12

I tried to cluster my data in accordance with the manual provided by the skmeans packages's manual page

我试图根据skmeans package的手册页提供的手册来对我的数据进行分组

I started by installing all required packages. I then imported my data table, and made a matrix out of it with:

我首先安装所有必需的包。然后导入我的数据表,用它做了一个矩阵:

x <- as.matrix(x)

# See dimensions
dim(x)
[1]  184 4000

When I try to hard partition my data into 5 clusters - as it is done in the manual's first example - like so:

当我尝试将我的数据硬划分为5个集群时——就像在手册的第一个示例中所做的那样——如下所示:

hparty <- skmeans(x, 5, control = list(verbose = TRUE))

I receive the following error message:

我收到以下错误信息:

Error in if (!all(row_norms(x) > 0)) stop("Zero rows are not allowed.") : 
missing value where TRUE/FALSE needed

And when I just type:

当我输入:

test <- skmeans(x, 5)

I get:

我得到:

Error in skmeans(x, 5) : Zero rows are not allowed.

I'm trying to figure out where this error is coming from, and why the function can't get a TRUE/FALSE value. Has anyone ever experienced this problem?

我想弄清楚这个错误来自哪里,为什么函数不能得到真值/假值。有人经历过这个问题吗?

Thank you in advance!

提前谢谢你!

1 个解决方案

#1


0  

Spherical means is k-means where every vector is normalized to length 1.

球形表示是k,表示每个向量归一化到长度为1。

If you have a constant 0 vector, this is not possible, and you cannot use spherical k-means (or cosine similarity).

如果你有一个常数0向量,这是不可能的,你不能使用球面k-means(或余弦相似)。

!all(row_norms(x) > 0))

is the test that you do not have a row of length 0.

是你没有一行长度为0的测试。

#1


0  

Spherical means is k-means where every vector is normalized to length 1.

球形表示是k,表示每个向量归一化到长度为1。

If you have a constant 0 vector, this is not possible, and you cannot use spherical k-means (or cosine similarity).

如果你有一个常数0向量,这是不可能的,你不能使用球面k-means(或余弦相似)。

!all(row_norms(x) > 0))

is the test that you do not have a row of length 0.

是你没有一行长度为0的测试。