【发布时间】:2016-04-04 22:12:07
【问题描述】:
可重现的数据:
Data <- data.frame(
X = sample(c(0,1), 10, replace = TRUE),
Y = sample(c(0,1), 10, replace = TRUE),
Z = sample(c(0,1), 10, replace = TRUE)
)
将数据帧转换为矩阵
Matrix_from_Data <- data.matrix(Data)
检查结构
str(Matrix_from_Data)
num [1:10, 1:3] 1 0 0 1 0 1 0 1 1 1 ... - attr(*, "dimnames")=2 个列表 ..$ : 空 ..$ : chr [1:3] "X" "Y" "Z"
问题: 我有二进制对称变量的数据框(比示例大),我想做一些层次聚类,这是我以前从未尝试过的。没有缺失值或 NA 值。
在尝试从“集群”包运行菊花函数之前,我将数据帧转换为矩阵,以获取相异矩阵。我想探索计算不同差异指标的选项,但遇到警告(不是错误):
library(cluster)
Dissim_Euc_Matrix_from_Data <- daisy(Matrix_from_Data, metric = "euclidean", type = list(symm =c(1:ncol(Matrix_from_Data))))
警告信息: 在 daisy(Matrix_from_Data, metric = "euclidean", type = list(symm = c(1:ncol(Matrix_from_Data)))) : 对于混合变量,自动使用度量“gower”
...这对我来说似乎很奇怪,因为“Matrix_from_Data”是所有数字变量,而不是混合变量。 Gower 可能是一个很好的指标,但我想看看其他指标如何影响集群。 我错过了什么?
【问题讨论】:
标签: r cluster-analysis