我可以使用 ggplot2 绘制气泡图。现在我想聚集一列然后做气泡图。我怎样才能做到这一点?这是情节的样子:图像看起来像这样
这是我的虚拟数据
x=data.frame(
group=c("A","A","B","B","C","C","C","D","D"),
item=c("apple","pear","apple","peach","orange","cherry","apple","banna","apple"),
count=c(3,5,5,1,9,7,3,2,4))
这是我的脚本:
library(ggplot2)
xf=x$item
xfu=unique(xf)
x$item=factor(xf,levels=xfu)
p<-ggplot(x)
p + geom_point(aes(x = group, y = item,size= count),las=2,shape=16,
alpha=0.80) +
scale_size_continuous(breaks=c(1,2,3,4,5,6,7,8,9),
labels=c("1","2","3","4","5","6","7","8","9"))+
theme(axis.text.x = element_text(angle = 45, hjust =
1.1,size=11,colour="black",face="bold"),
axis.text.y = element_text(size=11,colour="black"),
axis.title.y = element_text(size=12,colour =
"black",face="bold",vjust=0.12))+
labs(x="",y = "Item")
现在我想对项目数据进行层次聚类,以获得更明显的模式。项目的顺序并不重要。我怎样才能做到这一点?