How to perform clustering without removing rows where NA is present in R

不问归期 提交于 2019-11-30 04:14:22

The error is due to the presence of non-numeric variables in the data (numbers encoded as strings). You can convert them to numbers:

mydata <- apply( mtcars, 2, as.numeric )
d <- distfunc(mydata)

Using as.numeric may help in this case, but I do think that the original question points to a bug in the daisy function. Specifically, it has the following code:

    if (any(ina <- is.na(type3))) 
    stop(gettextf("invalid type %s for column numbers %s", 
        type2[ina], pColl(which(is.na))))

The intended error message is not printed, because which(is.na) is wrong. It should be which(ina).

I guess I should find out where / how to submit this bug now.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!