简体   繁体   English

R if (nrow(emobj$Mu):= nclass || ncol(emobj$Mu) != p || nrow(emobj$LTSigma) != 中的错误:需要 TRUE/FALSE 的地方缺少值

[英]R Error in if (nrow(emobj$Mu) != nclass || ncol(emobj$Mu) != p || nrow(emobj$LTSigma) != : missing value where TRUE/FALSE needed

I am getting the following error while using the EMCluster library in R:在 R 中使用 EMCluster 库时出现以下错误:

Error in if (nrow(emobj$Mu) != nclass || ncol(emobj$Mu) != p || nrow(emobj$LTSigma) !=  : 
missing value where TRUE/FALSE needed

This is the code I wrote:这是我写的代码:

emcluster(iris[,-5], pi = NULL, Mu = NULL, LTSigma = NULL,
      lab = NULL, EMC = .EMC, assign.class = FALSE)

I am using the Iris dataset.我正在使用 Iris 数据集。

My goal is to run an EM clustering algorithm and describe my observations through plots, etc.我的目标是运行一个 EM 聚类算法并通过绘图等来描述我的观察结果。

You need to provide the parameters, or you can initialize the EM and provide that:您需要提供参数,或者您可以初始化 EM 并提供:

library(EMCluster)

emobj <- simple.init(iris[,-5], nclass = 3)
mdl <- emcluster(iris[,-5], emobj = emobj, assign.class = TRUE)

table(mdl$class,iris$Species)
   
    setosa versicolor virginica
  1      0          0        15
  2      0         50        35
  3     50          0         0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM