title: Retrieve the non-zero values from array in R
body: <p>I have an array with size 31x36 in R called input_matrix. In each row of that matrix there are 16 non-zero values and 20 zero value. The indexes of non-zero values and zero values for each row are different. I want to retrieve as a final output of my system a matrix <code>output_matrix</code> with size 31x16 which contains the only non-zero values. An one-row example, if I have:</p>
  
  <pre><code>5 0 4 0 4 0 1 0 0 0 .. 1
  </code></pre>
  
  <p>I want to retrieve: <code>(5 4 4 1 ... 1)</code>. How can I do so in R?</p>