title: Selecting the first non 0 value in a row
body: <p>I have a large data frame of data from across months and I want to select the 
  first number that is not NA in each row. For instance ID 895 would correspond to the value in Feb15, 687. </p>
  
  <pre><code>  ID    Jan15   Feb15   Mar15   Apr15  
   ----- ------- ------- ------- ------- 
    100   NA      NA      NA      625    
    113   451     586     NA      NA     
    895   NA      687     313     17  
    454   NA      977     NA      146 
  </code></pre>
  
  <p>It would be helpful to store them in a variable so I could perform further calculations by month.</p>
  
  <pre><code>apply(tempdat[,32:43],1, function(x) head(which(x&gt;0),1))
  
  </code></pre>
  
  <p>This data frame contains thousands of rows so, is it possible to have the all the numbers returned for each month stored into their own new vars or one new data frame by month.</p>
  
  <p>In this case:</p>
  
  <pre><code>AggJan15 = 451
  AggFeb15 = 687
  AggMar15 = 0 
  AggApr15 = 625
  </code></pre>