title: How to deal with NA when using cut()?
body: <p>I have two binary files with (1440*720) the same dimensions: I want to take the average of my first file based on the  the second file values (intervals),the values of this file range from 1 to 7. whenever the values in the second file range between 0-1, calculate the corresponding average in the first file and return the result,do the same thing with 2-3,3-4,5-6,7-8.no data values are assigned as NA.</p>
  
  <p>1- to read the first file :</p>
  
  <pre><code>   conne &lt;- file("C:\\corr.bin","rb")
    corr&lt;- readBin(conne, numeric(), size=4,  n=1440*720, signed=TRUE)
  </code></pre>
  
  <p>2- to read the second file :</p>
  
  <pre><code>    conne1&lt;- file("C:\\use.bin","rb")
     cus&lt;- readBin(conne1, numeric(), size=4,  n=1440*720, signed=TRUE)
  
         cusBREAK &lt;- cut(cus,10:80))
        (corrMEAN &lt;- aggregate(corr, list(cusBREAK), mean))
  </code></pre>
  
  <p>But I got NAs,this mean that if there is NA in one of the pixels, will return the mean as NA.</p>
  
  <pre><code>        (corrMEAN &lt;- aggregate(corr, list(cusBREAK), mean))
        Group.1   x
       1   (0,1] NaN
       2   (1,2] NaN
       3   (2,3] NaN
       4   (3,4] NaN
       5   (4,5] NaN
  </code></pre>