I am curious about dist() output results that I get. More specifically, if I try
a=matrix(rnorm(1:100),nrow=10)
dist(a)
ok, I get what I expected
1 2 3 4 5 6 7 8 9
2 3.700582
3 3.793826 4.391523
4 3.063703 5.386797 5.494179
5 3.205545 4.464493 3.839944 3.763671
6 3.868796 4.954696 3.340530 5.165389 3.589912
7 3.906698 3.971069 3.405455 5.403859 4.284414 4.774963
8 2.620238 4.479064 5.403749 3.128820 4.237437 5.272889 5.551908
9 3.645784 4.586749 5.508289 3.333739 4.318391 6.113694 4.796519 3.641355
10 2.292591 4.152536 4.869231 3.445773 3.557222 3.992109 4.061925 3.740496 4.225799
Nice, but: when I have a larger matrix
dim(Large_m)
[1] 978 235
I try
a=dist(Large_m)
I do not get a matrix, rather a 'Large dist' object as Rstudio says.
Is it correct if I use it with as.matrix
?
b=as.matrix(a)
b as I checked is indeed a matrix and seems like the distance matrix.
Also, I really need the row names in the distance matrix, not just numbers but in this way (working with as.matrix
) I can't get it.
Seems I'm missing something, can't be so complicated to just create a distance matrix in R.