I need to show the results of a clustering. For demo, please see
library(ggplot2)
df = data.frame(cluster=c(1,1,2,2,2,3),states=c("AB","IN","UN","CH","LO","OK"))
p2<-ggplot(df,aes(x=1,y=states,fill=factor(cluster)))+
geom_tile()+
geom_text(aes(label=cluster))
p2
How can I
- Put the tiles with the same clustering number together?
- Show only 1 clustering number per cluster?
My code above is reproducible and I appreciate it if you just can tweak it a little. Thanks.