d <- ggplot(diamonds, aes(carat, depth, z = price))
d + stat_summary_hex()
# Specifying function
d + stat_summary_hex(fun = function(x) sum(x^2))
d + stat_summary_hex(fun = var, na.rm = TRUE)
Run the code above in your browser using DataCamp Workspace