Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)

岁酱吖の 提交于 2019-12-03 11:14:50

kmeans cannot handle data that has NA values.

The mean and variance are then no longer well defined, and you don't know anymore which center is closest.

Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)

This error occurs also due to non numeric values present in the table.

all of you all who are having " Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)" problem instead of

results <- kmeans(iris.features,3)
results

write the following and please be careful of the case in iris write whatever you have used in the beginning

results <- kmeans(na.omit(irisa.features),3) # this helps in omitting NA 
results
Muthu Raman Sivakumar

For error stating:

Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)

the dataset you have posted above contains scaled entries, the reason must be that you have NA values in your dataset, hence omit them by the following code.

km_cluster <- kmeans(na.omit(MyData), 3)
km_cluster
km_cluster$withinss
km_cluster$tot.withinss/km_cluster$betweenss
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!