I have a data frame with 10k rows and 3 columns: xpos, ypos and cluster (cluster is a number from 0 to 9) here: http://pastebin.com/NyQw29tb
I would like to show a hex plot with each hexagon colored according to the most-frequent cluster within that hexagon.
So far I've got:
library(ggplot2)
library(hexbin)
ggplot(clusters, aes(x=xpos, y=ypos, z=cluster)) + stat_summary_hex(fun.x=mode)
Which I think is giving me what I want (i.e. is filling in every hexagon with a color from 0 to 9), but the color scale appears continuous, and I can't figure out how to make it use a discrete one.
For extra context, here's the underlying, messier view of the data, which I'm trying to smooth out by using hexagons:
qplot(data=clusters, xpos, ypos, color=factor(cluster))