title: R: sum of rowSums off by one
body: <p>For my stats class, I'm using R to do some of the math for my term project. The class doesn't call for it, but I want to supplement myself by learning R, which is my weaker language.</p>
  
  <p>Using this data: <a href="https://github.com/paul-nelson-baker/math-1040-stats-project/blob/master/skittle-data.csv" rel="nofollow noreferrer">skittle-data.csv</a> (Every row was an individual bag of skittles submitted by each student)</p>
  
  <p>I'm trying to generate some charts and other things to satisfy the assignment. While doing so, I noticed that in determining the total number of skittles I was off by 1.</p>
  
  <p>When I load the csv into a dataframe I make summations of the rows, and then sum those summations to get the total, like this:</p>
  
  <pre><code>skittles = read.csv("skittle-data.csv", header = TRUE)
  columnTotals = colSums(skittles, na.rm=FALSE, dims = 1)
  rowTotals = rowSums(skittles, na.rm=FALSE, dims = 1)
  total = sum(rowTotals, na.rm=FALSE, dims = 1)
  
  print("Column Totals")
  print(columnTotals)
  
  print("Row Totals (individual bags)")
  print(rowTotals)
  
  print('Total skittles')
  print(total)
  </code></pre>
  
  <p>Running my code from my terminal outputs:</p>
  
  <pre><code>[1] "Column Totals"
     Red Orange Yellow  Green Purple
     269    289    296    295    300
  [1] "Row Totals (individual bags)"
   [1] 62 62 60 60 60 62 59 61 57 59 62 59 59 62 64 62 63 61 60 60 58 59 60 58
  [1] "Total skittles"
  [1] 1450
  </code></pre>
  
  <p>Yet excel shows the total number of skittles is 1449.</p>
  
  <p><a href="https://i.stack.imgur.com/Rfbr3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rfbr3.png" alt="skittle data - excel file"></a></p>
  
  <p>This is clearly user error on my part, but what is my mistake? Conceptually I think I've done this correctly so the only thing I can assume is that I've misunderstood some part of the summation functions (<code>colSums</code>, <code>rowSums</code>, or <code>sum</code>, etc)</p>