使用 ggplot2 可视化两步聚类
Vizualize two step cluster using ggplot2
spss 中有一种聚类,称为两步聚类。
spss 提供的 vizual 选项类似于 this 左侧图。
将聚类的结果、label/names 所使用的变量及其得分放入这样的数据框中
data.frame(cluster = c(1,1,1,2,2,2,3,3,3), value = c("Google","Amazon","Yahoo","Google","Amazon","Yahoo","Google","Amazon","Yahoo"), score = c(2194.2,43.2,4331.3,31.3,133.1,432.1,3234.1,44.3,21.4))
这些是 spss 图中引用的输入。
有什么有效的方法可以使用 ggplot2 将它们可视化吗?
也许是这样的:
library(ggplot2)
#Plot
ggplot(df,aes(x=cluster,y=score,fill=value))+geom_bar(stat='identity',position = 'stack')+
coord_flip()
spss 中有一种聚类,称为两步聚类。
spss 提供的 vizual 选项类似于 this 左侧图。
将聚类的结果、label/names 所使用的变量及其得分放入这样的数据框中
data.frame(cluster = c(1,1,1,2,2,2,3,3,3), value = c("Google","Amazon","Yahoo","Google","Amazon","Yahoo","Google","Amazon","Yahoo"), score = c(2194.2,43.2,4331.3,31.3,133.1,432.1,3234.1,44.3,21.4))
这些是 spss 图中引用的输入。
有什么有效的方法可以使用 ggplot2 将它们可视化吗?
也许是这样的:
library(ggplot2)
#Plot
ggplot(df,aes(x=cluster,y=score,fill=value))+geom_bar(stat='identity',position = 'stack')+
coord_flip()