title: simplest way to count number of ones in an array in R
body: <p>Is there a function which I can use to count the number of ones in an array in R?
  I was looking for something which would save me the overhead of</p>
  
  <pre><code>count = 0;
  myarray = c(1,1,0,1,0)  
  for(i in 1:length(myarray))
  {
   if(myarray[i] == 1)
   {
    count = count+1
   }
  }
  </code></pre>