How could I plot this kind of graph from stm modeling in R?

Hi, I'm new in R and thanks for welcoming me to this community.

I'm studying the stm topic modeling with R and read this paper What Students Learn in Economics 101: Time for a Change - UCL Discovery

I want to know how could I plot the graph like page 14 if I use stm?

Here is a start on doing that with a generic data frame.

library(ggplot2)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

DF <- data.frame(Topic = rep(LETTERS[1:3], each = 4),
                 Author = rep(c("", "Bob", "", "Amy"), 3),
                 Value = c(43, 22, -25, -18, 
                           26, 15, -33, -27,
                           55, 37, -17, -10))
DF1 <- DF %>% filter(Author == "")
DF2 <- DF %>% filter(Author != "")
ggplot(mapping = aes(Topic, Value)) + 
  geom_col(data = DF1, color = "black", fill = "white") + 
  geom_col(mapping = aes(fill = Author), data = DF2) +
  scale_fill_manual(values = c("Amy" = "grey80", "Bob" = "grey50") ) +
  ylim (-60, 60) + 
  coord_flip() + theme_minimal() +
  theme(panel.grid.major.x = element_blank(), 
          panel.grid.minor = element_blank())

Created on 2020-01-17 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.