根据LDA主题模型的结果,我试图创建30个水平条形图来显示顶部单词与其概率。
png("airport.png")
top_terms %>%
mutate(term = reorder(term, beta)) %>%
ggplot(aes(term, beta, fill = factor(topic))) +
geom_bar(stat = "identity", show.legend = FALSE) +
facet_wrap(~ topic, scales = "free") +
coord_flip()
dev.off()
以上代码会返回错误:
Error in facet_render.wrap(plot$facet, panel, plot$coordinates, theme, :
ggplot2 does not currently support free scales with a non-cartesian coord or coord_flip.
有什么建议吗?
我也尝试了以下内容:
png("airport.png")
top_terms %>%
mutate(term = reorder(term, beta)) %>%
ggplot(aes(beta, term, fill = factor(topic))) +
geom_bar(stat = "identity", show.legend = FALSE) +
facet_wrap(~ topic, scales = "free")
#coord_flip()
dev.off()
输出如下所示。问题是图表没有显示水平条。