How to sum array along 3rd dimension
<p>What is the canonical way to sum a 3D array along dimension 3 (thereby yielding a matrix)?</p>

<p>I know I can <code>apply(A,c(1,2),sum)</code> but (wrongly or rightly) I got the impression from somewhere that using <code>apply</code> is no better than using <code>for</code> loops.</p>

<p>I could probably <code>aperm</code> the array, <code>colSum</code> it, then un<code>aperm</code> it again, but that wouldn't be very readable.</p>

<p>Is there a better way?</p>