title: Convert and save distance matrix to a specific format
body: <p>I got a distance matrix with the following steps:</p>
  
  <pre><code>x &lt;- read.table(textConnection('
       t0 t1 t2
   aaa  0  1  0
   bbb  1  0  1
   ccc  1  1  1
   ddd  1  1  0
   ' ), header=TRUE)
  </code></pre>
  
  <p>As such <code>x</code> is a data frame with column and row headers</p>
  
  <pre><code>    t0 t1 t2
  aaa  0  1  0
  bbb  1  0  1
  ccc  1  1  1
  ddd  1  1  0
  
  require(vegan)
  d &lt;- vegdist(x, method="jaccard")
  </code></pre>
  
  <p>The distance matrix d is obtained as follows:</p>
  
  <pre><code>          aaa       bbb       ccc
  bbb 1.0000000                    
  ccc 0.6666667 0.3333333          
  ddd 0.5000000 0.6666667 0.3333333
  </code></pre>
  
  <p>By typing str(d), I found it is not a ordinary table nor csv format.</p>
  
  <pre><code>Class 'dist'  atomic [1:6] 1 0.667 0.5 0.333 0.667 ...
    ..- attr(*, "Size")= int 4
    ..- attr(*, "Labels")= chr [1:4] "aaa" "bbb" "ccc" "ddd"
    ..- attr(*, "Diag")= logi FALSE
    ..- attr(*, "Upper")= logi FALSE
    ..- attr(*, "method")= chr "jaccard"
    ..- attr(*, "call")= language vegdist(x = a, method = "jaccard")
  </code></pre>
  
  <p>I want to covert the distance matrix to a 3 columns with new headers and save it as a csv file as follows:</p>
  
  <pre><code>c1  c2  distance
  aaa bbb 1.000
  aaa ccc 0.6666667
  aaa ddd 0.5
  bbb ccc 0.3333333
  bbb ddd 0.6666667
  ccc ddd 0.3333333
  </code></pre>