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()
出力は以下のようになります。問題は、グラフに横棒が表示されないことです。