title: Plotting a hex bin in R and ggplot2 using a continuous Z fill variable
body: <p>My dataset has three variables: longitude (x), latitude (y), and a continuous variable that for these purposes I'm calling z.</p>
  
  <p>I am trying to use the stat_binhex function in the hexbin library to visualize the sum of z, rather than the count of (x,y) points, by hex bin. I know that there is a straightforward workaround for small sample sizes if I coerce z to a factor, but obviously this is neither feasible nor desirable with a large, continuous z. </p>
  
  <pre><code>library(ggplot2)
  library(hexbin)
  
  x &lt;- runif(1000, -125, -65)
  y &lt;- runif(1000, 25, 50)
  z &lt;- runif(1000, 1, 30000000)
  test &lt;- data.frame(x=x, y=y, z=z)
  
  p &lt;- ggplot(test, aes(x=x, y=y, fill=z))
  
  p &lt;- p + stat_binhex(binwidth=c(.5,.5))
  
  p
  
  &gt; Error in unit(tic_pos.c, "mm") : 'x' and 'units' must have length &gt; 0
  </code></pre>