title: label rows and columns of a sparse Matrix R
body: <p>I am trying to "label" the rows and columns of a dGC Matrix in R. I am getting inputs B (a matrix) and two lists "columns" and "rows". A representative minimal example is:</p>
  
  <pre><code>library(Matrix)
  B = matrix(c(0, 4, 0, 1, 0, 0), nrow=2,  ncol=3) 
  columns =c("c1","c2","c3")
  rows = c("row1","row2")
  as(B, "dgCMatrix") 
  </code></pre>
  
  <p>I would like to "label" the rows and columns of my dGC Matrix. In particular consider the following package:</p>
  
  <pre><code>install.packages("textir")
  library("textir")
  data(we8there)
  View(we8thereCounts)
  </code></pre>
  
  <p>My matrix should be like the "we8thereCounts" dgC Matrix provided as sample data in the "textir" package (intellectual credit to Matt Taddy of course). </p>
  
  <p>It seems most textual analysis packages for R automatically create these matrices (properly labeled), but I unfortunately inhert the data in this "raw" format. Can anyone point me to helpful commands? </p>
  
  <p>Thanks in advance!</p>
  
  <p>Edited: the number of columns to match my request. </p>