> install.packages("ggplot2") The downloaded binary packages are in /var/folders/nl/4z5wsxpn3cngl9tp9y17r5sm0000gn/T//RtmpwJmKSM/downloaded_packages > library("ggplot2", lib.loc="/Library/Frameworks/R.framework/Versions/3.0/Resources/library") > library(ggplot2)
It the last post there were some examples of how to plot some basic histograms and scatterplots (including a density distribution of BMI). Hexagon Binning is a form of bivariate histogram that excel’s when the size of the data set is >10^6 (Lewin-Koh, 2016).
> install.packages("hexbin") > ggplot(DS0012, aes(x=DS0012$height, y=DS0012$weight)) + geom_hex(bins=30) + xlab("Height [cm]") + ylab("Mass [kg]")
The presentation of the density plot changes dramatically when hexagons are used. It seems to have a much more fluid dynamic versus the harsh vertical and horizontal lines if squares were to be used for the same end.
This visualization also starts to show us where there are areas of dense concentration (right around 165cm and 70kg, and at 90cm and 20kg; not to mention the fact that it is quite a beautiful presentation).