title: R: colSums when not all columns are numeric
body: <p>I have the following data frame</p>
  
  <pre><code>Type   CA   AR
  alpha   1   5  
  beta    4   9 
  gamma   3   8 
  </code></pre>
  
  <p>I want to get the column and row sums such that it looks like this:</p>
  
  <pre><code>    Type   CA   AR Total
      alpha   1   5    6
      beta    4   9    13
      gamma   3   8    11
      Total   8   22   30
  </code></pre>
  
  <p>I am able to do rowSums (as shown above) I guess because they are all numeric. </p>
  
  <pre><code>colSums(df)
  </code></pre>
  
  <p>However, when I do colSums I get the error 'x must be numeric.' I realize that this is because the "Type" column is not numeric. </p>
  
  <p>If I do the following code such that I try to print the value into the 4th row (and only the 2nd through 4th columns are summed)</p>
  
  <pre><code>df[,4] = colSums(df[c(2:4)]
  </code></pre>
  
  <p>Then I get an error that replacement isn't same as data size.</p>
  
  <p>Does anyone know how to work around this? I want to print the column sums for columns 2-4, and leave the 1st column total blank or allow me to print "Total"?</p>
  
  <p>Thanks in advance!! </p>