14 Plotting Heatmap

Heatmap is useful when you want to display some aggregated values (frequency, average of a numeric column) against two categorical columns.

library(ggplot2)

data(diamonds)

d.agg = aggregate(price ~ color + cut, diamonds, mean)

ggplot(d.agg, aes(color, cut)) +

geom_tile(aes(fill = price)) +

scale_fill_gradient(low="lightblue", high="steelblue")