Error in do_one(nmeth) : NA/NaN/Inf in foreign fun

2019-03-25 08:52发布

I have a data table ("norm") containing numeric - at least to what I can see - normalized values of the following form:

A screenshot of the table

When I am executing

k <- kmeans(norm,center=3)

I am receving the following error:

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

Can you help me? Thank you!

4条回答
Root(大扎)
2楼-- · 2019-03-25 09:45

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.

查看更多
\"骚年 ilove
3楼-- · 2019-03-25 09:50

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
查看更多
疯言疯语
4楼-- · 2019-03-25 09:51

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
查看更多
Lonely孤独者°
5楼-- · 2019-03-25 09:52

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.

查看更多
登录 后发表回答