The base R heatmap function does a good job of generating basic heatmaps (this FlowingData tutorial showcases its capabilities), but if you want to put anything on the margins besides labels you're going to need something more powerful. The superheat package by Rebecca Barter (currently available only on GitHub) provides many additional capabilites for basic heatmaps (like ordering the rows/columns, or choosing a color scheme) and also the option to supercharge the heatmap with annotations and additional data visualizations in the margins. Here are a few examples:

Color the labels by another variable (here, Human Development Ranking, also represented as a bar chart — details and code here):

Or add dendrograms (perhaps from a clustering process) to the margins (details and code):

While the superheat pacakge uses the ggplot2 package internally, it doesn't itself follow the grammar of graphics paradigm: the function is more like a traditional base R graphics function with a couple of dozen options, and it creates a plot directly rather than returning a ggplot2 object that can be further customized. But as long as the options cover your heatmap needs (and that's likely), you should find it a useful tool next time you need to represent data on a grid.

The superheat package apparently works with any R version after 3.1 (and I can confirm it works on the most recent, R 3.3.2). This arXiv paper provides some details and several case studies, and you can find more examples here. Check out the vignette for detailed usage instructions, and download it from its GitHub repository linked below.