I suspect this to be a fairly straightforward question for coders more experienced than myself.
I'm doing sentiment analysis, comparing review-sentiments of two companies, and I am using the "introduction to tidytext" by Silge et al (2021) and the Jane Austin example as offset.
Instead of performing the analysis across the books I'm using the two companies, named Hawes and Curtis and Indochino.
The aim is to produce a plot similar to this using my own data.
This is the plot as it looks now:
This is the code from the paper:
bing <- get_sentiments("bing")
janeaustensentiment <- tidy_books %>%
inner_join(bing) %>%
count(book, index = line %/% 80, sentiment) %>%
spread(sentiment, n, fill = 0) %>%
mutate(sentiment = positive - negative)
library(ggplot2)
ggplot(janeaustensentiment, aes(index, sentiment, fill = book)) +
geom_bar(stat = "identity", show.legend = FALSE) +
facet_wrap(~book, ncol = 2, scales = "free_x")
This is my code:
bing <- get_sentiments("bing")
all_sentiment <- tokens_all %>%
inner_join( bing) %>%
count(company, index=line %/% 60, sentiment) %>%
spread(sentiment, n, fill = 0) %>%
mutate(sentiment = positive - negative)
ggplot(all_sentiment, aes(index, sentiment, fill= company)) +
geom_bar(stat = "identity", show.legend = FALSE)
facet_wrap(~company, ncol = 2, scales = "free_x")
This is shots of what the data looks like
Please let me know if you need the examples to be reproducible.
Thank you
Anders