title: Add all elements in matrix R
body: <p>I am trying to add all the elements in a matrix. This is an example of my matrix (the actual matrix is bigger): </p>
  
  <pre><code> m = matrix(c(528,479,538,603),nrow=2,ncol=2)
   m
                     A            B
  male              528          538
  female            479          603
  </code></pre>
  
  <p>I am trying to do:</p>
  
  <pre><code> sum.elements = colSums(colSums(m))
  </code></pre>
  
  <p>but it gives the following error:</p>
  
  <blockquote>
    <p>Error in colSums(colSums(m)) :    'x' must be an array of at least two
    dimensions</p>
  </blockquote>
  
  <p>I have tried doing:</p>
  
  <pre><code>x = colSums(m)
  sum.elements = x[1] + x[2]
  </code></pre>
  
  <p>but this would be very long when you have a 100-column matrix...</p>
  
  <p>Any help would be greatly appreciated!</p>