With the results of LDA topic model, I am trying to create 30 horizontal bar charts to show top words vs their probabilities.
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()
The above codes returns an error:
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.
Any suggestions?
I also tried the following:
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()
The output looks like below. The problem is the graph does not show horizontal bars.