library(tidyverse)
library(tidytext)
library(genius)
library(textdata)
library(wordcloud2)
library(ggplot2)
library(tibble)
library(textdata)
library(tokenizers)
library(magrittr)
library(purrr)
library(syuzhet)
library(circlize)
library(reshape2)
library(tm)library(viridisLite)
library(ggthemes)
library(RColorBrewer)
RdBu <- brewer.pal(8, "RdBu")
ChicksLyricsBefore <- TheChicksBefore %>%
add_genius(artist, title, type = "album")
data("stop_words")
ChicksLyricsBefore %>%
unnest_tokens(word, lyric) %>%
anti_join(stop_words) %>%
count(word, sort = TRUE) %>%
ungroup() %>%
head(200) %>%
wordcloud2(demoFreq, size = .6, shape = 'star', color = RdBu, backgroundColor = "gray") ChicksLyricsBefore %>%
unnest_tokens(word, lyric) %>%
anti_join(stop_words) %>%
count(word, sort = TRUE) %>%
head(10) -> Beforetop10
Beforetop10 %>%
ggplot(aes(reorder(word, -n), n, fill=word)) + geom_col() + scale_fill_brewer(palette = "RdBu") +
theme(legend.position="none") + theme_gray() + ggtitle("Top 10 Words of Dixie Chicks Albums Before 2003") + labs(y= "Number of Appearances", x = "Words")ChicksLyricsAfter %>%
unnest_tokens(word, lyric) %>%
anti_join(stop_words) %>%
count(word, sort = TRUE) %>%
head(200) %>%
wordcloud2(demoFreq, size = .4, shape = 'star', color = RdBu, backgroundColor = "grey") ## Joining, by = "word"
ChicksLyricsAfter %>%
unnest_tokens(word, lyric) %>%
anti_join(stop_words) %>%
count(word, sort = TRUE) %>%
head(10) -> Aftertop10## Joining, by = "word"
Aftertop10 %>%
ggplot(aes(reorder(word, -n), n, fill=word)) + geom_col() + scale_fill_brewer(palette = "RdBu") +
theme(legend.position="none") + theme_gray() + ggtitle("Top 10 Words of Dixie Chicks Albums After 2003") + labs(y= "Number of Appearances", x = "Words")library(devtools)
devtools::install_github('lchiffon/wordcloud2')## Skipping install of 'wordcloud2' from a github remote, the SHA1 (8a12a3b6) has not changed since last install.
## Use `force = TRUE` to force installation
library(wordcloud2)
force = TRUEChicksLyricsBefore <- TheChicksBefore %>%
add_genius(artist, title, type = "album")
data("stop_words")
SentimentBefore <- ChicksLyricsBefore %>%
unnest_tokens(word, lyric) %>%
anti_join(stop_words) %>%
count(word, sort = TRUE) %>%
head(20) %>%
ggplot(aes(word, n)) + geom_col ()
SentimentBefore <- ChicksLyricsBefore %>%
unnest_tokens(word, lyric) %>%
anti_join(stop_words) %>%
count(word, sort = TRUE) %>%
inner_join(get_sentiments("afinn"))
SentimentBefore %>%
head(20) %>%
ggplot(aes(reorder(word, n), n, fill=value)) +
geom_col() +
coord_flip() +
ylab("Number of Occurrences") +
xlab("Lyrics") +
ggtitle("Sentiment of Dixie Chicks Lyrics Before 2003 Controversy")TheChicksAfter <- tribble(
~artist, ~title,
"Dixie Chicks", "Taking The Long Way",
"Dixie Chicks", "Gaslighter",
)
ChicksLyricsAfter <- TheChicksAfter %>%
add_genius(artist, title, type = "album")
data("stop_words")
SentimentAfter <- ChicksLyricsAfter %>%
unnest_tokens(word, lyric) %>%
anti_join(stop_words) %>%
count(word, sort = TRUE) %>%
head(20) %>%
ggplot(aes(word, n)) + geom_col ()
SentimentAfter <- ChicksLyricsAfter %>%
unnest_tokens(word, lyric) %>%
anti_join(stop_words) %>%
count(word, sort = TRUE) %>%
inner_join(get_sentiments("afinn"))
SentimentAfter %>%
head(20) %>%
ggplot(aes(reorder(word, n), n, fill=value)) +
geom_col() +
coord_flip() +
scale_color_brewer(palette = "RdBu") +
ylab("Number of Occurrences") +
xlab("Lyrics") +
ggtitle("Sentiment of Dixie Chicks Lyrics After 2003 Controversy")summary(SentimentBefore) -> "SummaryBefore2003"
table(SummaryBefore2003)## SummaryBefore2003
## 1st Qu.: 1.000 1st Qu.:-2.0000 3rd Qu.: 4.000 3rd Qu.: 2.0000
## 1 1 1 1
## Class :character Length:190 Max. : 4.0000 Max. :152.000
## 1 1 1 1
## Mean : 4.126 Mean :-0.2842 Median : 1.500 Median :-1.0000
## 1 1 1 1
## Min. : 1.000 Min. :-4.0000 Mode :character
## 1 1 1
summary(SentimentAfter) -> "SummaryAfter2003"
table(SummaryAfter2003)## SummaryAfter2003
## 1st Qu.: 1.000 1st Qu.:-2.0000 3rd Qu.: 2.0000 3rd Qu.: 4.000
## 1 1 1 1
## Class :character Length:142 Max. : 4.0000 Max. :46.000
## 1 1 1 1
## Mean : 3.556 Mean :-0.2958 Median : 2.000 Median :-1.0000
## 1 1 1 1
## Min. : 1.000 Min. :-4.0000 Mode :character
## 1 1 1