Drawing a dendrogram from a pre-calculated distance matrix

I know there is another article like this, but that did not help me. I am trying to draw a dendrogram from a distance matrix that I calculated without using the Euclidean distance (using the distance from the globe from the emdist package). Now I am trying to conduct a dendrogram from this matrix:

dim(x)
[1] 8800 8800

x <- x[1:10,1:10]
x
          1        2        3          4         5        6        7
1  0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
2  0.67400563 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
3  0.02577228 0.6526842 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
4  0.37994900 0.7268372 0.1240314 0.0000000 0.0000000 0.0000000 0.0000000
5  0.85156584 1.0248822 0.6165767 0.9077611 0.0000000 0.0000000 0.0000000
6  0.51784015 0.5286874 0.5115762 0.6601093 1.1639417 0.0000000 0.0000000
7  0.19290720 0.5906327 0.6576926 0.4350795 0.2986499 0.4130357 0.0000000
8  1.57669127 1.3727582 1.4215065 1.9522834 1.0919793 0.9681544 1.0372481
9  3.01650143 3.3004177 3.0651622 3.2502077 4.1505108 2.9940774 3.6078234
10 0.48684093 0.6997258 0.3959822 0.3515030 0.8611233 0.5505790 0.3047047
         8       9    10
1  0.000000 0.000000   0
2  0.000000 0.000000   0
3  0.000000 0.000000   0
4  0.000000 0.000000   0
5  0.000000 0.000000   0
6  0.000000 0.000000   0
7  0.000000 0.000000   0
8  0.000000 0.000000   0
9  3.753577 0.000000   0
10 1.500342 3.309016   0

the problem is that I run

plot(hclust(x))

I get this error:

Error in if (is.na (n) || n> 65536L) stop ("size cannot be NA and exceeds 65536"): missing value that requires TRUE / FALSE

whereas if I run the dist function to calculate the Euclidean distances from the distance matrix that I already calculated using a different approach, it draws a graph.

plot(hclust(dist(x)))

enter image description here

. hclust , , . ?

+4
2

hclust dist. as.dist, dist, , .

plot(hclust(as.dist(x)))
+9

Source: https://habr.com/ru/post/1524375/


All Articles