title: convert matrix into dataframe in r
body: <p>I am trying to convert a matrix to a dataframe and use a column name and row name in the matrix with variables in the dataframe. <br>
  here is the sample <br></p>
  
  <pre><code>sample = matrix(c(1,NA,NA,2,NA,3,NA,NA,5,NA,NA,6,NA,NA,NA,NA,8,NA,3,1),ncol = 4)
  colnames(sample) = letters[1:4]
  row.names(sample) = letters[22:26]
  </code></pre>
  
  <p>My dataset has a lot of <code>NA</code> so I am trying to remove all the <code>NA</code> in the dataframe.</p>
  
  <p>so here is my desiring output,</p>
  
  <pre><code> data.frame(col = c("v","v","w","w","y","y","y","z"),
             row = c("a","b","c","c","a","b","d","d"), 
             value = c(1,3,6,8,2,5,3,1))
  </code></pre>