I want to make a heatmap that creates a group of clarity & color combinations as the X axis and cut as the Y axis. The heatmap would color based upon the counts of clarity+color and its intersection with the cut.
library(ggplot2)
library(dplyr)
## rename diamonds df
# 1. Generate a count for the frequency of cut+clarity
# 2. Make a heatmap of this using the following bins
# 3. Red <= 100 Frequency
Yellow = between (100 and 500)
Green > 500
# place counts inside the cell:
df = diamonds %>%
select( cut, clarity) %>%
group_by(cut,clarity)%>%
mutate(count = n())
myplot = ggplot(df, aes(x = clarity, y=cut)) +
geom_bin2d( bins = c(100,500,50000), col='orange') #
geom_text( aes(label = count),col='red')
myplot