Description Usage Arguments Details Value Note Examples
View source: R/AnalyzeSentiment.R
Analyze sentiment distribution across the article and plot it
1 | analyze_sentiment(url_end)
|
url_end |
a character string, an ending part of BBC News particular atricle URL (everything after https://www.bbc.com/news/). For example, article URL is "https://www.bbc.com/news/world-us-canada-51381625". Only "world-us-canada-51381625" should be pasted |
Use Corpus with article text without cleaning it as punctuation and stopwords should be preserved. Transform Corpus into a dataframe with one row for each article paragraph. Calculate sentiment score for each dataframe row and summary statistics for the entire article sentiment (mean, median, min, max). Build a dataframe with sentiment disrtibution and plot it
gg_plot with sentiment distibution across the article (sentiment > 0 positive and blue in color; sentiment < 0 negative and red in color)
Please, check that URL (url_end) exists before running the function, otherwise you will get an "Error in open.connection(x, "rb") : HTTP error 404". Please, insert URLs of the articles in English only. Only for BBC News, not BBC Sports , Travel, Worklife, etc.
1 2 | analyze_sentiment("world-us-canada-51381625")
analyze_sentiment("entertainment-arts-35232060")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.