Is there any R package to obtain a pairwise distance list if my input file is a distance matrix For eg, if my input is a data.frame like this:
A1 B1 C1 D1
A1 0 0.85 0.45 0.96
B1 0 0.85 0.56
C1 0 0.45
D1 0
I want the output as:
A1 B1 0.85
A1 C1 0.45
A1 D1 0.96
B1 C1 0.85
B1 D1 0.56
C1 D1 0.45
I found a question to do the opposite function using package 'reshape' but could not tweak it to get what I wanted.
dput(your-distance-object)
so we are not guessing whether you are actually dealing with adata.frame
, amatrix
, atable
, an actual distance matrix, or something else entirely. This would definitely influence the applicability of the answers presented so far. I ask this because your title says "distance matrix" (which is generally created using thedist
function), but your question description says you're dealing with adata.frame
. These are quite different. – Hamptondist
print the lower triangle by default, not the upper triangle. And are your blank cellsNA
, or simply hidden (as with theprint
method fordist
objects)? – Aventine