plot_net_sentiment_per_tag.Rd
Plot the difference between "net positive" and "net negative" sentiment in a text for each sentiment dictionary and class (if any).
plot_net_sentiment_per_tag( net_sentiment_all_dicts, target_col_name, title = NULL )
net_sentiment_all_dicts | A data frame from
|
---|---|
target_col_name | A string with the column name of the target variable. |
title | Plot title. Defaults to |
A ggplot
(ggplot::geom_col
).
library(experienceAnalysis) books <- janeaustenr::austen_books() # Jane Austen books emma <- paste(books[books$book == "Emma", ], collapse = " ") # String with whole book pp <- paste(books[books$book == "Pride & Prejudice", ], collapse = " ") # String with whole book # Make data frame with books Emma and Pride & Prejudice x <- data.frame( text = c(emma, pp), book = c("Emma", "Pride & Prejudice") ) calc_net_sentiment_per_tag(x, target_col_name = "book", text_col_name = "text") %>% plot_net_sentiment_per_tag( target_col_name = "book", title = "Net sentiment per book for each dictionary" )calc_net_sentiment_per_tag(x, target_col_name = NULL, text_col_name = "text") %>% plot_net_sentiment_per_tag( target_col_name = NULL, title = "Net sentiment in text for each dictionary" )