cluster-analysis - 使用 Daisy 获取 "invalid type character"错误

标签 cluster-analysis r-daisy

我有一个包含混合数据类型(整数、字符和逻辑)的数据框,我试图将其与 Daisy 聚类。

我正在使用:

gower_dist <- daisy(relchoice, metric = "gower")

并得到:

Error in daisy(relchoice, metric = "gower") : 
invalid type character for column numbers 3, 4, 5, 7, 8, 10, 13, 14, 15, 16, 
21, 29, 31, 32invalid type character for column numbers 3, 4, 5, 7, 8, 10, 
13, 14, 15, 16, 21, 29, 31, 32invalid type character for column numbers 3, 
4, 5, 7, 8, 10, 13, 14, 15, 16, 21, 29, 31, 32invalid type character for 
column numbers 3, 4, 5, 7, 8, 10, 13, 14, 15, 16, 21, 29, 31, 32invalid type 
character for column numbers 3, 4, 5, 7, 8, 10, 13, 14, 15, 16, 21, 29, 31, 
32invalid type character for column numbers 3, 4, 5, 7, 8, 10, 13, 14, 15, 
16, 21, 29, 31, 32invalid type character for column numbers 3, 4, 5, 7, 8, 
10, 13, 14, 15, 16, 21, 29, 31, 32invalid type character for column numbers 
3, 4, 5, 7, 8, 10, 13, 14, 15, 16, 21, 29, 31, 32invalid type character for 
column numbers 3, 4, 5, 7, 8, 10, 13, 14, 15, 16, 21, 29, 31, 32invalid type 
character for column numbers 3, 4, 5, 7, 8, 10, 13, 14, 15, 16, 21, 29, 31, 
32

希望得到一些帮助。

最佳答案

我能够通过将分类字段转换为因子数据类型来解决这个问题,例如:

df$job <- as.factor(df$job)

关于cluster-analysis - 使用 Daisy 获取 "invalid type character"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52522960/

相关文章:

apache-spark - 如何使用 KMeans 在 Spark 中对推文进行聚类?

python-3.x - sklearn - PCA 的标签点

Python:使用 scikit-learn 的 dbscan 进行字符串聚类,使用 Levenshtein 距离作为度量:

r - 计算大数据的差异矩阵

R:RStudio:如何使轮廓图工作?

r - R中缺少数据的聚类分析

python - 如何在 python 中绘制 k 距离图

R聚类 'purity'指标