My dataset has three variables: longitude (x), latitude (y), and a continuous variable that for these purposes I'm calling z.
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.
library(ggplot2)
library(hexbin)
x <- runif(1000, -125, -65)
y <- runif(1000, 25, 50)
z <- runif(1000, 1, 30000000)
test <- data.frame(x=x, y=y, z=z)
p <- ggplot(test, aes(x=x, y=y, fill=z))
p <- p + stat_binhex(binwidth=c(.5,.5))
p
> Error in unit(tic_pos.c, "mm") : 'x' and 'units' must have length > 0