Description Usage Arguments Value Examples
View source: R/plot_net_sentiment_long_nrc.R
Bar plots of NRC sentiment counts in one or more documents.
1 | plot_net_sentiment_long_nrc(net_sentiment_long_nrc)
|
net_sentiment_long_nrc |
A data frame from
|
A ggplot (ggplot::geom_col).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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")
)
# Net sentiment in each book
net_sentiment_wide_nrc <- calc_net_sentiment_nrc(x, target_col_name = "book",
text_col_name = "text",
filter_class = NULL)
net_sentiment_wide_nrc
# Tidy net_sentiment_wide_nrc and place the most "angry" book at the top
net_sentiment_long_nrc <- tidy_net_sentiment_nrc(net_sentiment_wide_nrc,
sorting_sentiments = "anger",
num_of_docs = 2) %>%
dplyr::select(-text)
net_sentiment_long_nrc
plot_net_sentiment_long_nrc(net_sentiment_long_nrc)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.