binMean1D() and binMean2D() improvements [but...]

... I am not really sure if I've done the x and y mapping right in the
indexing.  In any case, my goal is to get binMean2D() to give the same
answers as boxcarAverage2D() before I remove the latter.  Below is test
code (from src/bin.cpp) that shows a mismatch in array dimensions ...
why??

   library(oce)
   system("R CMD SHLIB bin.cpp") # must be in oce/src
   dyn.load("bin.so")
   set.seed(123)
   x <- rnorm(100, sd=1)
   y <- rnorm(100, sd=1)
   f <- x + y
   source('../R/misc.R')
   m <- binMean2D(x, y, f)
   a <- boxcarAverage2D(x, y, f, m$xmids, m$ymids)
   m$mean
   a$average
   cat("note mismatch above\n")