I want to do cluster analysis in R. So I create a distance matrix (Fig.1) below:
matrix_a <- data.frame(n1=c(0,1,11,5),n2=c(1,0,2,3),n3=c(11,2,0,4),n4=c(5,3,4,0))
Then I use the code below for cluster analysis:
result <- hclust(matrix_a,method="average")
However, an error occured:
Error in if (is.na(n) || n > 65536L) stop("size cannot be NA nor exceed 65536") : missing value where TRUE/FALSE needed
Could anyone help me check out where was I wrong?
hclust(as.dist(matrix_a), method = "average")
. The argument inhclust
needs to be of classdist
, not a matrix/data frame. – Nick Criswell