Here is a sample of my data: http://pastebin.com/pCbUnmqQ
I am attempting to make a hexbin plot where each bin is discretely colored by the most common name in that box. Something like the answer here.
used packages ggplot2 and library
I tried to use the code from the above question
ggplot(player, aes(x=X2, y=Y2, z=Name)) + stat_summary_hex(fun = function(z) {
+ tab <- table(z)
+ names(tab)[which.max(tab)]
+ })
but it was a mess with every single player having their own hexbins instead of one hexbin with the most common name being the color.
the code for the plot I want it to look the most like is
> ggplot(player, aes(x=X2, y=Y2)) + stat_binhex()
I want that but with each bin colored corresponding the player who appears there the most.